32

go代理设置

 3 years ago
source link: https://studygolang.com/articles/30772
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

在Go 1.13版本中,我们可以通过GOPROXY来控制代理,以及通过GOPRIVATE控制私有库不走代理。

设置GOPROXY代理:

go env -w GOPROXY=https://goproxy.cn,direct

设置GOPRIVATE来跳过私有库,比如常用的Gitlab或Gitee,中间使用逗号分隔:

go env -w GOPRIVATE=*.gitlab.com,*.gitee.com

如果在运行go mod vendor时,提示Get https://sum.golang.org/lookup/xxxxxx : dial tcp 216.58.200.49:443: i/o timeout,则是因为Go 1.13设置了默认的GOSUMDB= sum.golang.org ,这个网站是被墙了的,用于验证包的有效性,可以通过如下命令关闭:

go env -w GOSUMDB=off

可以设置 GOSUMDB="sum.golang.google.cn", 这个是专门为国内提供的sum 验证服务。

go env -w GOSUMDB="sum.golang.google.cn"

有疑问加站长微信联系

iiUfA3j.png!mobile

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK