Go 模块的全局代理。
A global proxy for go modules. see: https://goproxy.io
This service invokes the local go command to answer requests.
The default cacheDir is GOPATH, you can set it up by yourself according to the situation.
git clone https://github.com/goproxyio/goproxy.git
cd goproxy
make./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/testIf you run go get -v pkg in the proxy machine, you should set a new GOPATH which is different from the original GOPATH, or you may encounter a deadlock.
See test/get_test.sh.
./bin/goproxy -listen=0.0.0.0:80 -proxy https://goproxy.ioUse the -proxy flag combined with the -exclude flag to enable Router mode, which implements route filter to routing private modules or public modules.
direct
+----------------------------------> private repo
|
match|pattern
|
+---+---+ +----------+
go get +-------> |goproxy| +-------> |goproxy.io| +---> golang.org/x/net
+-------+ +----------+
router mode proxy modeIn Router mode, use the -exclude flag to set a glob pattern. The glob will specify what packages should not try to resolve with the value of -proxy. Modules which match the -exclude pattern will resolve direct to the repo which
matches the module path.
NOTE: Patterns are matched to the full path specified, not only to the host component.
./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/test -proxy https://goproxy.io -exclude "*.corp.example.com,rsc.io/private"Some private modules are gated behind git authentication. To resolve this, you can force git to rewrite the URL with a personal access token present for auth
git config --global url."https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/".insteadOf https://github.com/This can be done for other git providers as well, following the same pattern
docker run -d -p80:8081 goproxy/goproxyUse the -v flag to persisting the proxy module data (change cacheDir to your own dir):
docker run -d -p80:8081 -v cacheDir:/go goproxy/goproxydocker-compose upDeployment:
…Deployment (with gitconfig secret):
…export GOPROXY=http://localhost[:PORT] to use your goproxy.export GOPROXY=direct to directly access modules without your goproxy.暂无开放 Issues,或尚未同步最近议题。