Note: If you can not upgrade to 1.11 above, to download the package can be manually GOPATH corresponding directory, then input to the corresponding local uri Import;
Recent study golang , because of cultural self-confidence, Go language pack a lot of the country can not be obtained, writing this tutorial hope to help you solve the resource problem fastest wall, do not waste time on this meaningless things.
surroundings
-
$ go version # go version go1.12 darwin/amd64
-
Copy the code
- Golang upgrade to 1.11 (recommended 1.12 , after 1.11, go to the official introduction of the go module dependency management to solve the problem. This is a quick fix is the core of the wall.
Set GO111MODULE and GOPROXY
- The mac system, open end
-
$ vim .bash_profile
-
export GO111MODULE = on (1.13 can not, the default is on)
-
export GOPROXY=https://goproxy.io
-
- Execution
source ~/.bash_profile
; just make modifications to take effect immediately; - Open a new terminal , do not enter on a terminal interface
go env
; see ifGOPROXY="https://goproxy.io"
the configuration was successful; - Free download bag.
Related
- goproxy.io
- How to use go modules