Created
December 6, 2017 08:12
-
-
Save mosluce/28fe133db73fc2d98931832fc50c1d93 to your computer and use it in GitHub Desktop.
Serial port 列表 (USB、藍芽)...等
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
serial "go.bug.st/serial.v1" | |
) | |
func main() { | |
names, err := serial.GetPortsList() | |
reader := bufio.NewReader(os.Stdin) | |
if err != nil { | |
fmt.Printf("發生錯誤 : %s\n", err.Error()) | |
fmt.Println("press ENTER to end") | |
reader.ReadString('\n') | |
return | |
} | |
fmt.Println("=== USB 裝置清單 ===") | |
for i := range names { | |
fmt.Printf("%v. %s\n", i+1, names[i]) | |
} | |
fmt.Println("press ENTER to end") | |
reader.ReadString('\n') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment