Golang – go get private library prompt “410 gone” solution


I haven’t used a private library before, but I just came across it today. Let’s sort out the solutions


Error record

If you are using the go get private library, you will encounter the following error:





$ export GO111MODULE=on
$ export GOPROXY=direct
$ export GOSUMDB=off


We are familiar with go111module and goproxy, but the explanation of gosumdb is as follows:

We know that go will create a go.sum file locally when go module is enabled, which is used to store the encrypted checksums that depend on the specific version of the package. At the same time, go maintains the cache of the downloaded packages, and calculates and records the encrypted checksums of each package when downloading. In normal operation, the go command checks the go. Sum file under a repo against these pre computed checksums, instead of recalculating them every time the command is called.

In daily development, the checksums of specific module versions will never change. Every time it runs or builds, the go command will check whether the checksums of the local cache copies are consistent through the local go. Sum. If the checksums do not match, the go command reports a security error and refuses to run the build or run. In this case, it is important to find the correct checksums and determine whether the go. Sum error or the downloaded code is wrong. If the downloaded module is not included in go.sum and the module is a public module, the go command will query the go checksums database to get the correct checksums and store them in go.sum. If the downloaded code does not match the checksums, the go command reports the mismatch and exits.

Go 1.13 provides the gosumdb environment variable to configure the service address (and public key) of go checksums database. The default value is “sum. Golang. Org”, which is also the official checksums database service provided by go (for gopher in mainland China, you can use sum. Golang. Google. CN).

For security reasons, it is recommended to keep gosumdb on. However, if you cannot access gosumdb (even sum. Golang. Google. CN) due to some factors, you can close it by the following command:


go env -w GOSUMDB=off


After the gosumdb is closed, you can only use the local go. Sum to check the sum of packets.




Parameter test article: https://github.com/golang/go/issues/35164