Skip to content

Commit 98b3829

Browse files
committed
Fix duplication issues
1 parent 3e539da commit 98b3829

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

serial.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -472,22 +472,24 @@ func spListDual(network bool) {
472472
// happen on windows in a fallback scenario where an
473473
// open port can't be identified because it is locked,
474474
// so just solve that by manually inserting
475-
for port := range sh.ports {
475+
if network {
476+
for port := range sh.ports {
476477

477-
isFound := false
478-
for _, item := range list {
479-
if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) {
480-
isFound = true
478+
isFound := false
479+
for _, item := range list {
480+
if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) {
481+
isFound = true
482+
}
481483
}
482-
}
483484

484-
if !isFound {
485-
// artificially push to front of port list
486-
log.Println(fmt.Sprintf("Did not find an open port in the serial port list. We are going to artificially push it onto the list. port:%v", port.portConf.Name))
487-
var ossp OsSerialPort
488-
ossp.Name = port.portConf.Name
489-
ossp.FriendlyName = port.portConf.Name
490-
list = append([]OsSerialPort{ossp}, list...)
485+
if !isFound {
486+
// artificially push to front of port list
487+
log.Println(fmt.Sprintf("Did not find an open port in the serial port list. We are going to artificially push it onto the list. port:%v", port.portConf.Name))
488+
var ossp OsSerialPort
489+
ossp.Name = port.portConf.Name
490+
ossp.FriendlyName = port.portConf.Name
491+
list = append([]OsSerialPort{ossp}, list...)
492+
}
491493
}
492494
}
493495

0 commit comments

Comments
 (0)