go版本:

go version go1.13.6 windows/amd64

在使用下面命令准备安装gin试用一下时,发现,是不是卡主,然后直接报错:

go get -u github.com/gin-gonic/gin


go: finding github.com/gin-gonic/gin v1.5.0
go: downloading github.com/gin-gonic/gin v1.5.0
verifying github.com/gin-gonic/gin@v1.5.0: github.com/gin-gonic/gin@v1.5.0: Get https://sum.golang.org/lookup/github.com/gin-gonic/gin@v1.5.0: dial tcp 172.217.160.81:443: connectex: A connection attempt failed because the connected party did not properly respond a
fter a period of time, or established connection failed because connected host has failed to respond.

一开始非常的奇怪,单独拿地址也可以正常访问啊,因为本人vpn就没关过,关闭了VPN后发现地址竟然被墙了,坑爹,这为啥啊!

然后查了问题是自go1.13版本后设置了默认的GOSUMDB=sum.golang.org,但地址是被墙了的,需要命令关闭:

go env -w GOSUMDB=off

 重新运行安装命令,直接通过。

2021-11-22 更新

如果不可以可以考虑切换国内源,因为有些网络github访问受限

go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct