# 【Go第三方包代理】Go第三方包代理设置 — GOPROXY **Published by:** [eth.mirror.xyz](https://paragraph.com/@eth-mirror-xyz/) **Published on:** 2021-10-21 **URL:** https://paragraph.com/@eth-mirror-xyz/go-go-goproxy ## Content Go第三方包代理设置 — GOPROXY 由于国内 墙 的特殊存在,加上现在对翻墙软件的打压,想看看外面的世界越来越难了。 使用 Go 语言的小伙伴们应该也对 Go语言官网 被墙感到苦恼,很多文档和第三方包还得通过一些第三方渠道获得;尤其是 golang.org/x 使用广泛,但是被墙了。。。 Go 在 1.11 版本中放出了 mod 管理机制,在涉及到 第三方库 和 第三方库里用 golang.org/x 的时候,真是让人不爽。。。 下面来介绍一下 GOPROXY 方式去正常使用这些工具。 PS:可以翻墙的小伙伴可以略过所有内容。 一、传统非代理方式解决第三方包问题 go mod 提供了 replace 方式来指定替换包的地址;当然,如果第三方包中引用墙外的包,就需要手动修改他们了,不如代理方式方便; 使用方式如下: module github.com/exercise require ( golang.org/x/text v0.3.0 gopkg.in/yaml.v2 v2.1.0 ) replace ( golang.org/x/text => github.com/golang/text v0.3.0 ) 二、GOPROXY的两个地址 主要有两个地址: https://goproxy.io https://athens.azurefd.net 根据个人喜好随意选择吧。 1、goproxy.io 官网 原理图 2、Athens 官网 三、GoLand设置 路径:GoLand —> Perferences —> Go —> Go Modules(vgo)—> Proxy; 设置上面给出的地址; 重启即可使用; 四、命令行设置环境变量 此处以 Mac为例,给出示例图片; 只要 export 加入到 环境变量里,一些墙外的第三方包就可以正常获取到了; windows系统的设置方法可以看 goproxy.io 的设置文档; ~ $ export GOPROXY=https://goproxy.io ~ $ echo $GOPROXY https://goproxy.io 原文链接:https://blog.csdn.net/tmt123421/article/details/88665248 ## Publication Information - [eth.mirror.xyz](https://paragraph.com/@eth-mirror-xyz/): Publication homepage - [All Posts](https://paragraph.com/@eth-mirror-xyz/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@eth-mirror-xyz): Subscribe to updates