The problem and solution of “410 gone” prompted by golang’s go get private library

Time:2020-10-27

I haven’t used the private library before, but I happened to encounter it today. Let’s sort out the solution

Error record

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

resolvent


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

Both go111module and goproxy are familiar, while gosumdb is described as follows:

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

In daily development, the checksums for specific module versions never change. Each time you run or build, the go command passes through the local go.sum To check whether the checksums of its local cache copies are consistent. 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’s important to find the correct checksums and make sure they are go.sum Error or download code is wrong. If go.sum If there is no downloaded module in, and the module is a public module, the go command will query the go checksums database to obtain the correct checksums and save the 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 for configuring the service address (and public key) of the go checksums database. The default value is sum.golang.org ”This is also the official check sum database service provided by go (gopher in mainland China can use it sum.golang.google .cn)。

For safety reasons, it is recommended to keep gosumdb on. But if, for some reason, gosumdb cannot be accessed (or even sum.golang.google . CN), which can be turned off by the following command:

go env -w GOSUMDB=off

After gosumdb is shut down, only local go.sum Check and verify the packet.

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

              https://tonybai.com/2019/10/27/some-changes-in-go-1-13/

Knowledge points supplement:

Solutions to go get timeout

go get gopkg.in/yaml . V2 timed out. It was found that it was blocked. The solution is as follows:

1. Installation golang.org/x/net


$ mkdir -p $GOPATH/src/golang.org/x/
$ git clone https://github.com/golang/net.git $GOPATH/src/golang.org/x/net
$ go install net

2. Installation gopkg.in/yaml .v2

$ go get gopkg.in/yaml.v2

summary

The above is the details of the problem and solution of “410 gone” prompted by golang’s go get private library. For more information about go get private library, please pay attention to other related articles in developeppaer!

Recommended Today

Java security framework

The article is mainly divided into three parts1. The architecture and core components of spring security are as follows: (1) authentication; (2) authority interception; (3) database management; (4) authority caching; (5) custom decision making; and;2. To build and use the environment, the current popular spring boot is used to build the environment, and the actual […]