About me

The article start | my blog | welcome the attention

Due to some force majeure reasons, the problem of timeout often occurs when the go GET command is used to install packages in China. This article describes several common solutions.

Out of cloning

Golang on dead simple to set up a image libraries, such as https://github.com/golang/net is corresponding to the https://golang.org/x/net image libraries. To download the golang.org/x/net package, you can create the package directory locally and use git Clone to pull the corresponding package source file, as follows:

mkdir -p $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/net.git
Copy the code

Using gopm

Gopm can be downloaded from several mirror sites at Golang.org.

Install gopm

go get -u github.com/gpmgo/gopm
Copy the code

Install third-party packages using Gopm

Without the -g parameter, the dependent package will be downloaded from the vendor directory. With the -g parameter, you can download the dependent packages to the GOPATH directory.

gopm get -g golang.org/x/net  
Copy the code

Using goproxy

After version 1.11 of Go, you can set the variable GOPROXY to set the proxy. If you have your own proxy server you can set this environment variable to your own proxy. First enable go Module support:

Run on Mac/ Linux:

export GO111MODULE=on
Copy the code

Windows platform implementation:

SET GO111MODULE=on
Copy the code

2019.6.10 update: goproxy. Cn

Here we take https://goproxy.cn as an example:

On Mac/ Linux, you can run the following command to set it:

export GOPROXY=https://goproxy.cn
Copy the code

Windows Platform run the following command in CMD to set:

SET GOPROXY="https://goproxy.cn"
Copy the code

Or execute in PowerShell:

C:\> $env:GOPROXY = "https://goproxy.cn"
Copy the code

Recommended reading

New open source has emerged after Redis tools were charged

The highest engineer skills chart on GitHub

Chinese programmers are most prone to mispronounce words

Recommended!!!!!! Markdown icon index site

END

Welcome to pay attention to the public number programmer tool set 👍👍 is committed to sharing excellent open source projects, learning resources, common tools

Reply keyword “attention package”, send you a complete map of programmer skills.