Error reading repository - Error 410

My company uses private Gitlab installation (let’s call it git.company.com), and some Goland projects are referencing other private repositories as dependencies.

I was very perplexed when, while downloading such dependencies with go get (those projects were not under go mod), I got a following error:

1reading https://sum.golang.org/lookup/git.company.org/[email protected]: 410 Gone

Turns out, that from go 1.13, a proxy is used to resolve packages

When resolving a package path to its containing module, the go command will try all candidate module paths on each proxy in the list in succession. An unreachable proxy or HTTP status code other than 404 or 410 terminates the search without consulting the remaining proxies.

https://golang.org/doc/go1.13#modules

and since that proxy cannot access a private repository, a 410 error is being thrown.

Fortunately it’s fairly simple fix:

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.

https://golang.org/doc/go1.13#modules

Just create an environmental variable (or put it directly in your .bashrc file) with following value

1export GOPRIVATE="gitlab.com/repo1,bitbucket.org/repo2,github.com/repo3,git.company.com"

As you can see, it’s possible to set a specific rule for a specific repositories, or on a global level (for some specific domain)

Copyright

Comments