The Go get command USES the methods of the socket agent

  • 2020-06-19 10:29:08
  • OfStack

For reasons that cannot be described, some packages installed with the go get command in China fail to time out, such as net packages, sys packages, tools packages, etc. The first solution is to download from git and add a link to GOPATH, such as:


git clone https://github.com/golang/net.git $GOPATH/src/github.com/golang/net
git clone https://github.com/golang/sys.git $GOPATH/src/github.com/golang/sys
git clone https://github.com/golang/tools.git $GOPATH/src/github.com/golang/tools
ln -s $GOPATH/src/github.com/golang $GOPATH/src/golang.org/
cd $GOPATH/src/golang.org/ && mv golang x

The other is the use of agents. http agents are mostly used on the Internet. Here is how to use socket agents. The go get command also USES the git command to download, but it will automatically compile and install after downloading, so first set the git agent:


git config --global http.proxy socks5://127.0.0.1:7070

then


http_proxy=socks5://127.0.0.1:7070 go get xxxx

Just fine.

You can reset the git configuration if you restore:


git config --global --unset http.proxy

The go get command USES the socket agent

For reasons that cannot be described, some packages installed with the go get command in China failed due to timeout, such as net, sys, tools, and so on. The first solution is to download from git and add a link to GOPATH, such as:


git clone https://github.com/golang/net.git $GOPATH/src/github.com/golang/net
git clone https://github.com/golang/sys.git $GOPATH/src/github.com/golang/sys
git clone https://github.com/golang/tools.git $GOPATH/src/github.com/golang/tools
ln -s $GOPATH/src/github.com/golang $GOPATH/src/golang.org/
cd $GOPATH/src/golang.org/ && mv golang x

The other is the use of agents. http agents are mostly used on the Internet. Here is how to use socket agents. go get command actually USES git command to download, but it will automatically compile and install after downloading, so first set the git agent:


git config --global http.proxy socks5://127.0.0.1:7070

then


http_proxy=socks5://127.0.0.1:7070 go get xxxx

Just fine.

If restored, you can reset the git configuration:

git config --global --unset http.proxy

Let's look at how go get USES the proxy

For well-known reasons, the go get command was blocked while extracting 1 project or dependency (e.g. golang.org domain name). This can be resolved by using the vpn or proxy approach.

Buy VPN

I won't go into that, but the vpn is the equivalent of a direct connection.

Using the agent

By shell environment variable


export http_proxy=http://ip:port
go get golang.org/xxx

Set up the git agent

This is also the official go guidance.


git config  � global http.proxy 'http://127.0.0.1:8087'
go get golang.org/xxx

To use the goagent agent, use the set git agent and execute the following script in addition to go get:


git config --global http.sslCAinfo 'pathto/XX-Net-3.6.15/data/gae_proxy/CA.crt'

conclusion

Above is the site to introduce Go get command to use socket agent, I hope to help you, if you have any questions welcome to leave a message, this site will promptly reply you!


Related articles: