SoFunction
Updated on 2025-03-03

How to use socket proxy for Go get command

Due to some undescribable reasons, the timeout will be caused by the timeout when installing certain packages using the go get command in China, such as net package, sys package, tools package, etc. The first solution is to download it from git and add the link to GOPATH, for example:

git clone /golang/ $GOPATH/src//golang/net
git clone /golang/ $GOPATH/src//golang/sys
git clone /golang/ $GOPATH/src//golang/tools
ln -s $GOPATH/src//golang $GOPATH/src//
cd $GOPATH/src// && mv golang x

In addition, it is to use a proxy. Most of the Internet uses http proxy. Here is a record of how to use a socket proxy. The go get command actually uses the git command to download, but it will be automatically compiled and installed after downloading, so first set the git proxy:

git config --global  socks5://127.0.0.1:7070

Then

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

That's it.

If you restore, you can reset the git configuration:

git config --global --unset 

The go get command uses socket proxy

Due to some undescribable reasons, the timeout will be caused by the timeout when installing certain packages using the go get command in China, such as net package, sys package, tools package, etc. The first solution is to download it from git and add the link to GOPATH, for example:

git clone /golang/ $GOPATH/src//golang/net
git clone /golang/ $GOPATH/src//golang/sys
git clone /golang/ $GOPATH/src//golang/tools
ln -s $GOPATH/src//golang $GOPATH/src//
cd $GOPATH/src// && mv golang x

In addition, it is to use a proxy. Most of the Internet uses http proxy. Here is a record of how to use a socket proxy. The go get command actually uses the git command to download, but it will be automatically compiled and installed after downloading, so first set the git proxy:

git config --global  socks5://127.0.0.1:7070

Then

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

That's it.

If you restore, you can reset the git configuration:

git config --global --unset

Let's take a look at the method of using go get

For well-known reasons, the go get command is dropped by a wall when extracting some projects or dependencies (such as domain names). It can be solved by using vpn or proxy.

Buy a VPN

I won’t say much about this. Buying vpn is equivalent to direct connection.

Using a proxy

Through shell environment variables

export http_proxy=http://ip:port
go get /xxx

Setting up git proxy

This is also the official guidance of Go.

git config –global  'http://127.0.0.1:8087'
go get /xxx

If you use * proxy, please use the method of setting up a git proxy, and execute the following scripts and then go get:

git config --global  'pathto/XX-Net-3.6.15/data/gae_proxy/'

Summarize

The above is the Go get command introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time!