Windows: fixed port enumeration

This commit is contained in:
Stepan
2025-03-28 16:28:13 +09:00
parent 3449d2e7f6
commit 5069d66aa2

View File

@@ -45,12 +45,22 @@ func nativeGetPortsList() ([]string, error) {
} }
defer key.Close() defer key.Close()
list, err := key.ReadValueNames(0) names, err := key.ReadValueNames(0)
if err != nil { if err != nil {
return nil, &PortError{code: ErrorEnumeratingPorts, causedBy: err} return nil, &PortError{code: ErrorEnumeratingPorts, causedBy: err}
} }
return list, nil var values []string
for _, n := range names {
v, _, err := key.GetStringValue(n)
if err != nil || v == "" {
continue
}
values = append(values, v)
}
return values, nil
} }
func (port *windowsPort) Close() error { func (port *windowsPort) Close() error {