How to fetch modules from private repository

back to go get

Fix: go get private repository return error reading sum.golang.org/lookup … 410 gone 1

Fixing error: go get gomodule on private module with error message pattern verifying git-host… reading sum.golang.org/lookup … 410 gone 1

Using GOPRIVATE

As stated in the release doc of Go 1.13,

The new GOPRIVATE environment variable indicates module paths that are not publicly available. It serves as the default value for the lower-level GONOPROXY and GONOSUMDB variables, which provide finer-grained control over which modules are fetched via proxy and verified using the checksum database.

export GOPRIVATE="gitlab.com/idmabar,bitbucket.org/idmabar,github.com/idmabar"

And to verify if this worked, you can do the go env command.

(GOPRIVATE="gitlab.com/idmabar,bitbucket.org/idmabar,github.com/idmabar" go env) | grep GOPRIVATE

So this env-variable will tell the go get command to use the private host proxy to retrieve the package.

Using GONOSUMDB

Another solution, maybe using the GONOSUMDB variable.

So try to set this in as an environment variable:

export GONOSUMDB="gitlab.com/idmabar,bitbucket.org/idmabar,github.com/idmabar"

Actually this issue only happens in new Golang version 1.13 and afterward.

Miscellaneous

  • clone repo and run GOINSECURE=true go get
    • troubleshooting