Due to some force majeure, domestic use go get
will often issue a timeout occurs when the installation package command. This article describes some common solutions.
Clone from github
golang image library established on a github, as https://github.com/golang/net
it is corresponding to https://golang.org/x/net
the image library. To download golang.org/x/net
the package, the package can create directories on the local use of git clone
the source code files to pull respective packets, as follows:
mkdir -p $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/net.git
Use gopm
Use gopm can be downloaded from some golang.org mirror sites.
Installation gopm
go get -u github.com/gpmgo/gopm
Use gopm install third-party packages
Without -g
parameters, dependencies will download .vendor
directory; with -g
parameters, can be dependent package to GOPATH
the directory.
gopm get -g golang.org/x/net
Use goproxy
Go version 1.11 can be set later GOPROXY
this variable to set the proxy. If you have a proxy server you can put the environment variable to your agent. First of all open go module
support:
Performed in the Mac / linux:
export GO111MODULE=on
Windows platform to perform:
SET GO111MODULE=on
2019.6.10 update: goproxy.cn
We here at https://goproxy.cn
an example:
In Mac / linux you can execute the following command to set:
export GOPROXY=https://goproxy.cn
Windows platform in cmd
executing the following command set:
SET GOPROXY="https://goproxy.cn"
Or in PowerShell
execution:
C:\> $env:GOPROXY = "https://goproxy.cn"