go包下载失败,go get下载失败解决方案,go get golang.org/x 包失败,go代理,goproxy.io

大家都知道,在go工程里引用了墙外的包,导致无法下载所需要的第三方包。

要解决这个问题就是加代理。

网上各种设置各种换代理的方式我都试过不行,昨天找到一个可行方案,亲测mac,windows都可以正常使用。而且速度还很快哦。

Bash (Linux or macOS)

# Set the GOPROXY environment variable
export GOPROXY=https://goproxy.io,direct
# Set environment variable allow bypassing the proxy for specified repos (optional)
export GOPRIVATE=git.mycompany.com,github.com/my/private

PowerShell (Windows)

# Set the GOPROXY environment variable
$env:GOPROXY = "https://goproxy.io,direct"
# Set environment variable allow bypassing the proxy for specified repos (optional)
$env:GOPRIVATE = "git.mycompany.com,github.com/my/private"

官网:GOPROXY.IO

这个不仅好用,设置也简单。只需要执行命令行配置环境变量就好。

有问题可以留言,有建议欢迎指出。

猜你喜欢

转载自blog.csdn.net/Lyon_Nee/article/details/102637028