在 Linux 或 macOS 上面
需要运行下面命令(或者,可以把以下命令写到 .bashrc 或 .bash_profile 文件中):
# 启用 Go Modules 功能
go env -w GO111MODULE=on# 配置 GOPROXY 环境变量,以下三选一# 1. 七牛 CDNgo env -w GOPROXY=https://goproxy.cn,direct# 2. 阿里云go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct# 3. 官方go env -w GOPROXY=https://goproxy.io,direct# 确认一下:
$ go env | grep GOPROXY
GOPROXY="[https://goproxy.cn](https://goproxy.cn/)"
在Windows上面
# 启用 Go Modules 功能
$env:GO111MODULE="on"# 配置 GOPROXY 环境变量,以下三选一# 1. 七牛 CDN
$env:GOPROXY="https://goproxy.cn,direct"# 2. 阿里云
$env:GOPROXY="https://mirrors.aliyun.com/goproxy/,direct"# 3. 官方
$env:GOPROXY="https://goproxy.io,direct"# 确认一下:
$ go env | grep GOPROXY
GOPROXY="[https://goproxy.cn](https://goproxy.cn/)"