go get github.com/tarm/goserial
package main import ( "log" serial "github.com/tarm/goserial" ) func main() { //设置串口号和波特率 s := &serial.Config{Name: "com1", Baud: 9600} //打开串口 _, err := serial.OpenPort(s) if err != nil { log.Fatal(err) } }
go get github.com/tarm/goserial
package main import ( "log" serial "github.com/tarm/goserial" ) func main() { //设置串口号和波特率 s := &serial.Config{Name: "com1", Baud: 9600} //打开串口 _, err := serial.OpenPort(s) if err != nil { log.Fatal(err) } }