How to solve the problems related to go package Management
This article shows you how to solve the problems related to go package management, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. Download the walled package
Export GO111MODULE=on
Export GOPROXY= https://goproxy.io
Easily solve problems such as the following: go get golang.org/x/sys: unrecognized import path "golang.org/x/sys" (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 216.239.37.1) 443: iMago timeout)
There are some repo we do not want to use as agents, such as the company's internal repo, which needs to be set separately: export GOPRIVATE= "gitlab.xxx.com" GONOPROXY= "gitlab.xxx.com"
Export GOPROXY=direct, turn it off.
two。 Access to private warehouses using ssh protocol
Go env-w GOPRIVATE=gitlab.xxx.com
Question: fatal: could not read Username for 'https://gitlab.xxx.com': terminal prompts disabled
Method: git config-- add-- global url. "git@gitlab.xxx.com:" .Einstein of https://gitlab.xxx.com
Reference: https://erwinvaneyk.nl/private-repositories-with-go-mod/
3 Update go mod
Go get-d gitlab.xxx.com/xxx/containerd@80c0ab87fbe6888064cd243aa6a6be77aa7968bf delete private repo in go.mod, delete private repo in requires, and update it in replace as follows: github.com/containerd/containerd v1.4.0 = > gitlab.xxx.com/xxx/containerd v0.0.0-20201202101137-80c0ab87fbe6
Then refresh: go mod vendor
4 go mod tidy: checksum mismatch problem
Go clean-modcache rm go.sum go mod tidy
5. Vndr
Containerd project, using the following: vndr github.com/containerd/cri 362dc5e4e008912d93876d0d194ab0bf6a469aa2 git@gitlab.xxx.com:eci-depend/cri.git
6. Gosum
Background: https://goproxy.io/zh/docs/GOSUMDB-env.html
Error: go get-d gitlab.xxx.com/yyy/cri@zzz
Go: k8s.io/node-problem-detector@v0.0.0-000101000000-000000000000 requires github.com/euank/go-kmsg-parser@v2.0.1+incompatible: verifying go.mod: github.com/euank/go-kmsg-parser@v2.0.1+incompatible/go.mod: reading https://goproxy.io/sumdb/sum.golang.org/lookup/github.com/euank/go-kmsg-parser@v2.0.1+incompatible: 410 Gone server response: not found: github.com/euank/go- Kmsg-parser@v2.0.1+incompatible: invalid version: + incompatible suffix not allowed: module contains a go.mod file So semantic import versioning is required
Solution: export GOSUMDB=off
The above content is how to solve the problems related to go package management. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.