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.gitUse gopmUse gopm to download from some mirror websites of golang.org. Install gopm
go get -u github.com/gpmgo/gopm
Use gopm to install third-party packagesWithout the -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/netUse goproxyAfter version 1.11 of Go, you can set the
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=onExecute on Windows platform:
SET GO111MODULE=on2019.6.10 update: goproxy. cnWe take
https://goproxy.cn as an example:
export GOPROXY=https://goproxy.cnFor Windows platform, execute the following command in
cmd to set:
SET GOPROXY="https://goproxy.cn"or execute in
PowerShell:
C:\> $env:GOPROXY = "https://goproxy.cn"