1.首先開啟go module
go env -w GO111MODULE=on // Windows
export GO111MODULE=on // macOS 或 Linux
2.配置goproxy:
阿里配置:
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/ // Windows
export GOPROXY=https://mirrors.aliyun.com/goproxy/ // macOS 或 Linux
七牛云配置:
go env -w GOPROXY=https://goproxy.cn // Windows
export GOPROXY=https://goproxy.cn // macOS 或 Linux
注意:
Go 1.13設置了默認的GOSUMDB=sum.golang.org,是用來驗證包的有效性崇棠。這個網(wǎng)址由于墻的原因可能無法訪問蔗崎,所以可以使用下面命令來關閉:
go env -w GOSUMDB=off // Windows
export GOSUMDB=off // macOS 或 Linux