Skip to main content

_env-vars

Private modules are only accessible to authorized users and cannot be pulled through the default module proxy at https://proxy.golang.org or have their checksums verified with the public checksum database at https://sum.golang.org/. To access private modules you need to specify a combination of GOPROXY, GOPRIVATE, GONOPROXY and/or GONOSUMDB.

There are two possible ways to configure go for private modules:

  • Using GOPRIVATE=buf.build/gen/go. This implicitly sets GONOPROXY/GONOSUMDB to the same value, causing go to use the direct strategy for fetching directly from BSR without going through the public proxy.

    NOTE: Due to GONOPROXY including the buf registry, this is not compatible with specifying auth directly in GOPROXY. Only netrc based auth is supported in this configuration.

  • Using GOPROXY=https://buf.build/gen/go,$GOPROXY and GONOSUMDB=buf.build/gen/go. This instructs go to try a module from the buf from buf before falling back to the exisiting configured proxies. This works both for netrc and direct authentication.

Modify the Go environment using the export command in your shell or with the go env -w command to persist the change.

    $ export GONOSUMDB=$GONOSUMDB,buf.build/gen/go

For more information, see the official private modules documentation.