_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 setsGONOPROXY
/GONOSUMDB
to the same value, causing go to use thedirect
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 inGOPROXY
. Only netrc based auth is supported in this configuration.Using
GOPROXY=https://buf.build/gen/go,$GOPROXY
andGONOSUMDB=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.
- Temporary
- Persist
$ export GONOSUMDB=$GONOSUMDB,buf.build/gen/go
$ go env -w GONOSUMDB=$GONOSUMDB,buf.build/gen/go
For more information, see the official private modules documentation.