報錯情況
下載gin
包,報錯如下:
unrecognized import path "golang.org/x/crypto/sha3": https fetch: Get "https://golang.org/x/crypto/sha3?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.
unrecognized import path "google.golang.org/protobuf/encoding/prototext": https fetch: Get "https://google.golang.org/protobuf/encoding/prototext?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.
如圖:
解決方案
設置代理
cmd
下輸入:SET GO111MODULE=on
接着cmd
輸入:SET GOPROXY=https://goproxy.cn
這里參考的文章上是:
在代理鏈接外添加了雙引號,但是事實上:
出現了轉義
go get github.com/gin-gonic/gin: parse "\"https://goproxy.cn\"": first path segment in URL cannot contain colon
所以這里我們靈活修改為 SET GOPROXY=https://goproxy.cn
代理設置完成,成功下載