Go 由于是谷歌研发出品,很多开源依赖包都在国外服务器,down包经常会出现当不下来的情况,此时就需要设置$GOPROXY 代理,通过国内代理链接来获取包资源。
常用代理路径:GOPROXY.IO - A Global Proxy for Go Modules
网站打开很直白的介绍了如何设置$GOPROXY变量。
In Linux or macOS, you can execute the below commands.
Bash /
# Enable the go modules feature
export GO111MODULE=on
# Set the GOPROXY environment variable
export GOPROXY=https://goproxy.io
Or, write it into the .bashrc or .bash_profile file.
In Windows, you can execute the below commands.
PowerShell
# Enable the go modules feature
$env:GO111MODULE=on
# Set the GOPROXY environment variable
$env:GOPROXY=https://goproxy.io
Now, when you build and run your applications, go will fetch dependencies via goproxy.io. See more information in the goproxy repository.
If your Go version >= 1.13, the GOPRIVATE environment variable controls wh