1、引用Mqtt包
MQTT "github.com/eclipse/paho.mqtt.golang"
2、异常报错
dial tcp 142.251.43.17:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
进入GO_PATH/src/golang.org/x目录下
git clone https://github.com/golang/net.git
进入 GO_PATH/src/golang.org/x/net/websocket
go build
返回GO_PATH/src/golang.org/x目录下
go get github.com/eclipse/paho.mqtt.golang
3、还不行 cmd 查看配置
go env
go env -w GOSUMDB=off
go env -w GOPROXY=https://goproxy.cn,direct
回到2即可

浙公网安备 33010602011771号