参考:https://blog.csdn.net/qq_45914985/article/details/109555913
系统:Windows10
首先要有一个代理服务器,然后可以在系统设置中的“网络和Internet管理”中找到代理的地址和端口。
第一步先配置Git代理,实际使用中只配置http代理就可以正常用了。
//命令行输入,代理地址替换为自己的
设置http/https代理:
git config --global http.proxy http://127.0.0.1:8080
git config --global https.proxy https://127.0.0.1:8080
查看设置的代理:
git config --global http.proxy
git config --global https.proxy
第二部打开一个cmd窗口,配置临时代理。
设置临时代理(仅在该cmd窗口中有效,关闭cmd取消设置):
set http_proxy=http://127.0.0.1:1080
set https_proxy=http://localhost:1080
取消代理设置:
set http_proxy=
查看代理设置:
set http_proxy
接下来使用go get命令就可以正常访问了。
如果有长期的稳定代理,比如 https://goproxy.io/zh/ 就可以按照其手册上推荐的设置环境变量来实现。(比较推荐这个,基本上可以正常使用go get命令了)
$env:GOPROXY = "https://goproxy.io,direct"