In Linux or macOS, you can execute the below commands.
1 2 3 4
# Enable the go modules feature export GO111MODULE=on # Set the GOPROXY environment variable export GOPROXY=https://goproxy.io
Or, write it into the .bashrc or .bash_profile file.
In Windows, you can execute the below commands.
PowerShell Copy
1 2 3 4
# Enable the go modules feature $env:GO111MODULE="on" # Set the GOPROXY environment variable $env:GOPROXY="https://goproxy.io"
Now, when you build and run your applications, go will fetch dependencies via goproxy.io. See more information in the goproxy repository.
If your Go version >= 1.13, the GOPRIVATE environment variable controls which modules the go command considers to be private (not available publicly) and should therefore not use the proxy or checksum database. For example:
Go version >= 1.13 Copy
1 2 3
go env -w GOPROXY=https://goproxy.io,direct # Set environment variable allow bypassing the proxy for selected modules go env -w GOPRIVATE=*.corp.example.com
<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-XBYBL322DY"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());
10.19.114.100 宿主机路由 #ip route -n default via 10.19.114.1 dev eth0 10.19.114.0/24 dev eth0 proto kernel scope link src 10.19.114.100 10.250.250.0/24 dev eth1 proto kernel scope link src 10.250.250.100 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 172.20.0.0/24 dev cni0 proto kernel scope link src 172.20.0.1 172.20.1.0/24 via 172.20.1.0 dev flannel.1 onlink 172.20.2.0/24 via 172.20.2.0 dev flannel.1 onlink
1 2 3 4 5 6 7 8 9
10.19.114.101 宿主机路由 #ip route -n default via 10.19.114.1 dev eth0 10.19.114.0/24 dev eth0 proto kernel scope link src 10.19.114.101 10.250.250.0/24 dev eth1 proto kernel scope link src 10.250.250.101 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 172.20.0.0/24 via 172.20.0.0 dev flannel.1 onlink 172.20.1.0/24 dev cni0 proto kernel scope link src 172.20.1.1 172.20.2.0/24 via 172.20.2.0 dev flannel.1 onlink