GOPROXY_golang_golang菜鸟教程

golang 代理工具——goproxy

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中移出即可

原文链接:,转发请注明来源!