155 字
1 分钟
go之切换代理
参考链接
解决go被墙的问题
有两种方式,一种是直接从github下载对应项目的代码,然后编译安装到go的src目录下 【目录】/src/golang.org/x/ ,二种是切换代理(推荐)
手动下载
cd %GOPATH%/src/golang.org/x/git clone https://github.com/golang/crypto.git# 安装编译这个包下的所有依赖go install golang.org/x/crypto/...切换代理
window:
go env -w GO111MODULE=ongo env -w GOPROXY=https://goproxy.io# https://goproxy.io 也可替换成阿里云的 https://mirrors.aliyun.com/goproxy或https://goproxy.cn,directlinux
export GO111MODULE=onexport GOPROXY=https://goproxy.cn# 或者使用以下echo "export GO111MODULE=on" >> ~/.profileecho "export GOPROXY=https://goproxy.cn" >> ~/.profilesource ~/.profile