百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

goproxy

> 编程语言
开源

Go 模块的全局代理。

5.9K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Go 模块的全局代理。

GOPROXY

A global proxy for go modules. see: https://goproxy.io

Requirements

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.

Build

bash
git clone https://github.com/goproxyio/goproxy.git
cd goproxy
make

Started

Proxy mode

bash
./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/test

If 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.

Router mode

bash
./bin/goproxy -listen=0.0.0.0:80 -proxy https://goproxy.io

Use 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 mode

In 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.

bash
./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/test -proxy https://goproxy.io -exclude "*.corp.example.com,rsc.io/private"

Private module authentication

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

bash
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

Use docker image

bash
docker run -d -p80:8081 goproxy/goproxy

Use the -v flag to persisting the proxy module data (change cacheDir to your own dir):

bash
docker run -d -p80:8081 -v cacheDir:/go goproxy/goproxy

Docker Compose

bash
docker-compose up

Kubernetes

Deployment:

…

Deployment (with gitconfig secret):

…

Appendix

  • If running locally, set export GOPROXY=http://localhost[:PORT] to use your goproxy.
  • Set export GOPROXY=direct to directly access modules without your goproxy.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogogolanggoproxymodule

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言