goproxy 一个全球代理, 为 Go 模块而生
https://goproxy.io
Linux or macOS
# 配置 GOPROXY 环境变量
export GOPROXY=https://goproxy.io,direct
# 还可以设置不走 proxy 的私有仓库或组,多个用逗号相隔(可选)
export GOPRIVATE=git.mycompany.com,github.com/my/private
Windows PowerShell工具
# 配置 GOPROXY 环境变量
$env:GOPROXY = https://goproxy.io,direct
# 还可以设置不走 proxy 的私有仓库或组,多个用逗号相隔(可选)
$env:GOPRIVATE = git.mycompany.com,github.com/my/private
Goproxy 中国
中国最可靠的 Go 模块代理。
Goproxy 中国完全实现了 Go 的模块代理协议。并且它是一个由中国备受信赖的云服务提供商七牛云支持的非营利性项目。
Go 及以上(推荐)
打开你的终端并执行:
$ go env -w GOPROXY=https://goproxy.cn,direct
完成。
macOS 或 Linux
打开你的终端并执行:
$ export GOPROXY=https://goproxy.cn
或者
$ echo export GOPROXY=https://goproxy.cn >> ~/.profile && source ~/.profile
完成。
Windows PowerShell
打开你的 PowerShell 并执行:
C:\> $env:GOPROXY = https://goproxy.cn
或者
1. 打开开始并搜索“env”
2. 选择编辑系统环境变量
3. 点击环境变量...按钮
4. 在<你的用户名> 的用户变量章节下(上半部分)
5. 点击新建...按钮
6. 选择变量名输入框并输入GO111MODULE
7. 选择变量值输入框并输入on
8. 点击确定按钮
9. 点击新建...按钮
. 选择变量名输入框并输入GOPROXY
. 选择变量值输入框并输入https://goproxy.cn
. 点击确定按钮
完成。
常见的问题:
$GOPATH/go.mod exists but should not
开启模块支持后,并不能与GOPATH共存,所以把项目从GOPATH中移出即可