golang uses a proxy download module, goproxy

Here is https://goproxy.io

If using Go version 1.13 and above (recommended)

go env - w GO111MODULE = on 
go env - w GOPROXY = https: // goproxy.io, direct 

# Set the private warehouse without proxy, multiple separated by commas (optional) 
go env - w GOPRIVATE = *. corp. example.com

If you are using Go version 1.12 and below

Bash (Linux or macOS)

# Enable Go Modules function 
export GO111MODULE = on 
# Configure GOPROXY environment variable 
export GOPROXY = https: // goproxy.io

Or, the above command is written to ~ / .profileor ~ / .bash_profile,如果bash使用的zsh请写入到~/.zshrcfile for a long time.

PowerShell (Windows)

# Enable Go Modules function 
$ env : GO111MODULE = " on " 
# Configure GOPROXY environment variable 
$ env : GOPROXY = " https://goproxy.io "

 

View agent:

 go env | grep GOPROXY

Cancel agent:

#Cancel the proxy set with go envs- w: 
go env - u GOPROXY 
go env - u GO111MODULE #Modify the 
configuration file 
Delete the line added in the configuration file

 

 

Guess you like

Origin www.cnblogs.com/eingstein/p/12727044.html