Go Modules
go getgolang.org/xgo buildGOPATH/pkg/mod
- GOPROXY
- Athens
GOPROXY
$GOPROXY//@v/list$GOPROXY//@v/.info$GOPROXY//@v/.mod$GOPROXY//@v/.zip
通过命令:
export GOPROXY=https://goproxy.io
go module download protocolproxymoduleGOPROXYGOPROXY
详见: https://github.com/goproxyio/goproxy
Athens
Athens 是一个建立在 vgo(或者是1.11 +)之上的项目,试图让依赖关系更接近你,即使在 VCS 关闭时你也可以依赖可重复的构建。
依赖关系是来自 Github 的不可变的代码块和相关的元数据。 他们存储在 Athens 控制的仓库里。
v1.2.3
安装
Athens 支持多种方式的安装,docker 容器、k8s 和二进制安装包,本文将会介绍如何通过二进制包安装。
git clone https://github.com/gomods/athens
cd athens
make build-ver VERSION="0.2.0"
./athens -version
获取私有仓库
.netrc
.netrc
//.netrc
machine github.com
login MY_USERNAME
password MY_PASSWORD
本地应用
export GO111MODULE=on
export GOPROXY=http://127.0.0.1:3000
walkthrough
git clone https://github.com/athens-artifacts/walkthrough.git
$ cd ../walkthrough
$ go run .
go: finding github.com/athens-artifacts/samplelib v1.0.0
handler: GET /github.com/athens-artifacts/samplelib/@v/v1.0.0.info [200]
handler: GET /github.com/athens-artifacts/samplelib/@v/v1.0.0.mod [200]
go: downloading github.com/athens-artifacts/samplelib v1.0.0
handler: GET /github.com/athens-artifacts/samplelib/@v/v1.0.0.zip [200]
The ? says rawr!
go run .github.com/athens-artifacts/samplelib
global public proxy
athens.azurefd.net
export GOPROXY="https://athens.azurefd.net"
当然虽然可以使用这些公有的代理,但是包的源并不是很全,最稳妥的方法还是自建 Athens 服务。官方issue中所说:
athens.azurefd.netAthens