基本逻辑完成

This commit is contained in:
2024-11-01 17:40:34 +08:00
commit f9b9beea4b
40 changed files with 1869 additions and 0 deletions

28
pkg/relay/portlist.go Normal file
View 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)
}
}
}