Set up Goproxy.cn
Configure the proxy for local development and CI, and set up access to private modules.
Quickstart
Choose a configuration method and run its command in the corresponding shell.
go env -w GOPROXY=https://goproxy.cn,directThis saves the setting in Go's per-user configuration.
Run go env GOPROXY to check the current value.
To remove the saved setting, run go env -u GOPROXY.
An existing GOPROXY environment variable takes precedence over the value written by go env.
Continuous integration
Set GOPROXY in your build job's environment. This is a job-level GitHub Actions example.
env:
GOPROXY: https://goproxy.cn,directPrivate modules
Add the path prefixes of your private modules to GOPRIVATE before downloading dependencies. Replace the example prefix with your own. This command replaces the saved list, so include any existing entries, separated by commas.
go env -w GOPRIVATE=git.example.comIf you set GONOPROXY or GONOSUMDB separately, see the Go documentation on private modules for how they override the defaults and match module paths.
Proxy fallback
,direct tells Go to try version control directly if the proxy returns HTTP 404 or 410. A timeout or another HTTP error stops the download.
If the download still fails, use the download diagnostics to check your connection.
Run your own Go module proxy
Goproxy.cn is built on the open-source Goproxy project. The Goproxy deployment guide explains how to run the server from the command line or use Goproxy as an HTTP handler in a Go application.
Run these commands in Bash or Zsh. Before starting the server, make sure the directory where Go installs binaries is on your PATH. The server needs a module cache separate from the client's.
go install github.com/goproxy/goproxy/cmd/goproxy@latest &&
GOMODCACHE=/tmp/goproxy-gomodcache goproxy server --address localhost:8080To try the server, set the client's GOPROXY to http://localhost:8080.