基本逻辑完成
This commit is contained in:
28
pkg/relay/portlist.go
Normal file
28
pkg/relay/portlist.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"go.bug.st/serial/enumerator"
|
||||
)
|
||||
|
||||
func PrintPorts() {
|
||||
ports, err := enumerator.GetDetailedPortsList()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if len(ports) == 0 {
|
||||
return
|
||||
}
|
||||
for _, port := range ports {
|
||||
fmt.Printf("Port: %s\n", port.Name)
|
||||
if port.Product != "" {
|
||||
fmt.Printf(" Product Name: %s\n", port.Product)
|
||||
}
|
||||
if port.IsUSB {
|
||||
fmt.Printf(" USB ID : %s:%s\n", port.VID, port.PID)
|
||||
fmt.Printf(" USB serial : %s\n", port.SerialNumber)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user