使用GitHub上的eclipse/paho.mqtt.golang包时,长时间无响应后,弹出以下错误提示
$ go get github.com/eclipse/paho.mqtt.golang
package golang.org/x/net/proxy: unrecognized import path “golang.org/x/net/proxy” (https fetch: Get https://golang.org/x/net/proxy?go-get=1: dial tcp 216.239.37.1: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 get无法拉取我们所需包的源码,从goproxy的官网上的使用分布图就能很明显的看出来:

此时修改一下环境变量启动GOPROXY,再用go get -v即可,-v参数能够显示go get执行的进度
# Enable the go modules feature
export GO111MODULE=on
# Set the GOPROXY environment variable
export GOPROXY=https://goproxy.io
当使用Go语言开发并尝试通过go get命令拉取eclipse/paho.mqtt.golang包时,因网络问题遇到连接超时错误。本文介绍了解决此问题的方法,通过设置GOPROXY环境变量指向goproxy.io,成功解决了依赖包拉取失败的问题。

被折叠的 条评论
为什么被折叠?



