报错信息
$ go get golang.org/x/net/websocket
unrecognized import path "golang.org/x/net/websocket": https fetch: Get "https://golang.org/x/net/websocket?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 中撞墙,即便挂着vpn仍然无法下载
尝试过 go get层面增加代理也没能解决(本身代理地址是阿里云镜像)
go 1.11版本新增了 GOPROXY 环境变量,go get会根据这个环境变量来决定去哪里取引入库的代码
$ export GOPROXY=https://goproxy.io
最终解决方案
$mkdir -p $GOPATH/src/golang.org/x/
$cd $GOPATH/src/golang.org/x/
$git clone https://github.com/golang/net.git net
$go install net
手动克隆库到本地环境
再执行go get 安装(如: go get golang.org/x/net/websocket)
即可安装成功