How to solve the problem that golang failed to get the dependency package of golang.org when using the go get command to install the project from github?

I know that because golang.org is outside the wall, there is no need to talk about online methods.
originally go get is an one-button command, and all dependencies are installed automatically. I manually clone all dependencies on github according to the package name and copy them to the corresponding directory. What experience is there in this installation process?
Why is it that package management in other languages, such as php"s composer,node npm, can modify the configuration to a domestic mirror source, and then install dependent packages painlessly, while golang cannot?
I have searched so much information that all I see is manual! Manual! Manual!

Apr.25,2022

The reason why

does not work is that go writes the domain name directly when relying on remote packages, while the dependent packages rely on packages from another domain.

Why use a domain name? My guess:

  1. go doesn't want dependent libraries to be in github, but he doesn't want to give up github
  2. you can build your own dependency library

is there any way to solve it?

because of the domain name, the package that a project depends on may come from many domain names (that is, go's library does not only provide a centralized unified library like other languages), so a single domestic image cannot solve the problem.

of course, if you like, you can try this (purely brainstorming):

1. Set up your own go library image (may need to be collected from multiple places, and may also have to solve the problem of the same name)

  1. overwrite the go get command. If you encounter a domain name dependency, use your own image
to interpret the built-in domain name.

this problem is really quite a headache. There are probably no domestic problems preventing at least one group of people from using golang!


set the SS proxy for the command line, and then climb over the wall to execute go get. If it is Linux/Unix/Mac, you can refer to: http://lessisbetter.site/2018...


look back, well, you can use goproxy

.
Menu