I am working on a Windows application written in Go lang, and I need to programmatically determine the number of physical USB ports available on the system.
My requirement is:
The count should represent physical USB ports (host controller / hub ports)
The count must not change when USB devices are plugged in or removed
I am not looking for the number of currently connected USB devices
The solution must work on Windows
Preferably accessible or callable from Go (golang), either directly or via Windows APIs (SetupAPI, WMI, etc.)
So far, most approaches I’ve found (WMI queries like Win32_USBHub, Win32_PnPEntity, or SetupDi enumeration) return logical devices, and the count changes when devices are attached or detached.
Questions:
Is it possible on Windows to reliably get the number of physical USB ports?
Which Windows API or system interface exposes this information (e.g., USB host controller topology, hub descriptors)?
Has anyone implemented this in Go, or can provide guidance on calling the required Windows APIs from Go?
Any examples, documentation links, or explanations of Windows USB topology would be appreciated