報錯信息
$ 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)
即可安裝成功