go get command to install packages in China. This article introduces several common solutions.
https://github.com/golang/net corresponding to
https Mirror library at ://golang.org/x/net. To download the
golang.org/x/net package, you can create the package directory locally and use
git clone to pull the source code file of the corresponding package. The specific operations are as follows:
mkdir -p $GOPATH/src/golang.org/x cd $GOPATH/src/golang.org/x git clone https://github.com/golang/net.git
go get -u github.com/gpmgo/gopm
Copy after login
Use gopm to install third-party packagesWithout the go get -u github.com/gpmgo/gopm
-g parameter, the dependent package will be downloaded
.vendorUnder the directory; Add the
-g parameter to download the dependent package to the
GOPATH directory.
gopm get -g golang.org/x/net
GOPROXY variable 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:
export GO111MODULE=on
SET GO111MODULE=on
https://goproxy.cn as an example:
export GOPROXY=https://goproxy.cn
cmd to set:
SET GOPROXY="https://goproxy.cn"
PowerShell:
C:\> $env:GOPROXY = "https://goproxy.cn"