在 Debian 上设置 Golang 代理(通常指 Go 模块代理 GOPROXY),常见做法如下:
export GOPROXY=https://proxy.golang.org,direct
国内推荐:
export GOPROXY=https://goproxy.cn,direct
或
export GOPROXY=https://goproxy.io,direct
编辑 ~/.bashrc 或 ~/.profile:
nano ~/.bashrc
添加:
export GOPROXY=https://goproxy.cn,direct
export GOSUMDB=off # 可选,关闭校验(不推荐生产)
生效:
source ~/.bashrc
sudo nano /etc/profile.d/go.sh
写入:
export GOPROXY=https://goproxy.cn,direct
保存后重启或:
source /etc/profile
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOSUMDB=off # 可选
查看:
go env GOPROXY
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
go get github.com/gin-gonic/gin
https://goproxy.cnhttps://goproxy.iohttps://mirrors.aliyun.com/goproxy/如果你是指 apt 代理 或 git 代理,也可以告诉我。