Windows 下 go get 等命令使用 HTTP 代理(非 GOPROXY)

Windows 下 go get 等命令使用 HTTP 代理(非 GOPROXY)

日暮清林
2024-04-20 / 0 评论 / 10 阅读 / 正在检测是否收录...

前言

折腾了半天,设置了 HTTP_PROXY 也不行,最后发现必须小写。

教程

​​‌‌​​​‌‌​‌​​‌‌‍​‌​‌‌‌​​‌‌‌‌​‌​‍​‌​​‌​​​‌​​​‌‌​‍​‌​‌‌​​​‌‌​​​​​‍​​‌​‌‌‌‌‌‌‌‌​​​‍​‌‌​​‌‌‌​‌‌​​‌‌‌‍​‌‌​​​‌‌‌​​​‌​‌‍​​‌‌‌‌‌‌‌‌​​‌‌‍‌​‌​‌​​​‍‌​​‌​‌‌​‍‌​​‌​​​‌‍‌​​‌‌​‌‌‍‌​​‌​​​​‍‌​​​‌​​​‍‌​​​‌‌​​‍‌‌​‌‌‌‌‌‍​‌‌​​​‌‌‌‌‌​‌​​‍‌‌​‌‌‌‌‌‍‌​​‌‌​​​‍‌​​‌​​​​‍‌‌​‌‌‌‌‌‍‌​​‌‌​​​‍‌​​‌‌​‌​‍‌​​​‌​‌‌‍‌‌​‌‌‌‌‌‍​​​​‌​​‌​‌‌​‌‌​‍​‌​‌​‌‌‌​​​​​‌​‍​‌‌​​​‌​​​‌‌​‌‌‍​‌‌​​​​‌​​​​​​​‍​​​‌​‌​‌‌​‌​‌‌‌‍‌‌​‌‌‌‌‌‍‌​‌‌​‌‌‌‍‌​‌​‌​‌‌‍‌​‌​‌​‌‌‍‌​‌​‌‌‌‌‍‌‌​‌‌‌‌‌‍​‌‌​​​‌​​​‌‌‌​​‍​​​‌​‌‌‌‌‌‌‌​​‌‍​​​​​​​​‌‌‌‌​‌‌‌‍​‌‌​‌​​​‌​‌​​​​‌‍‌‌​‌‌‌‌‌‍‌​‌‌‌​​​‍‌​‌‌​​​​‍‌​‌​‌‌‌‌‍‌​‌​‌‌​‌‍‌​‌‌​​​​‍‌​‌​​‌‌‌‍‌​‌​​‌‌​‍​​​​​​​​‌‌‌‌​‌‌​‍​​‌‌‌‌‌‌‌‌​​‌​‍​​​​​​​​‌‌‌‌​​‌‌‍​​​‌​‌​‌‌​​‌‌‌​‍‌​‌‌​​‌‌‍‌​​‌‌​‌​‍‌​​​‌​​‌‍‌​​‌​‌‌​‍‌​‌​​​​​‍‌​‌‌​​‌​‍‌​​‌‌‌‌​‍‌​​​‌‌​‌‍‌​​​‌​​‌‍‌​​‌​‌‌​‍‌​​‌​​​‌‍​‌‌​​​‌​‌‌‌​​​‌‍‌‌​​‌‌​‌‍‌‌​​‌‌‌‌‍‌‌​​‌‌​‌‍‌‌​​‌​‌‌‍‌‌​‌​​‌​‍‌‌​​‌‌‌‌‍‌‌​​‌​‌‌‍‌‌​‌​​‌​‍‌‌​​‌‌​‌‍‌‌​​‌‌‌‌‍​‌​‌‌​‌‌‌‌​​‌​​‍​‌‌​​​​‌​‌​​​‌‌‍​​​​​​​​‌‌‌‌​​‌‌‍​‌​‌‌​​​‌‌​​​​​‍​​‌‌​‌​​‌‌‌‌​​​‍​‌​‌​​​‌‌​​‌‌‌‌‍​‌​‌​​​‌​‌‌‌‌‌‌‍​​​​​​​​‌‌‌​​‌​‌‍‌​​‌​‌‌‌‍‌​​​‌​‌‌‍‌​​​‌​‌‌‍‌​​​‌‌‌‌‍‌​​​‌‌​​‍‌‌​​​‌​‌‍‌​‌​​​‌‌‍‌​‌​​​‌‌‍‌​​‌​‌​​‍‌​​​​‌‌​‍‌​​‌​​‌‌‍‌​​‌​‌‌​‍‌​​‌​​​‌‍‌‌​‌​​​‌‍‌​​​‌‌​​‍‌​​​‌​‌​‍‌​‌​​​‌‌‍‌​​​‌​‌‌‍‌​​​‌​‌​‍‌​​​‌​‌‌‍‌​​‌​​​​‍‌​​​‌‌​‌‍‌​​‌​‌‌​‍‌​​‌‌‌‌​‍‌​​‌​​‌‌‍‌​​​‌‌​​‍‌​‌​​​‌‌‍‌​​​‌​‌​‍‌​​​‌‌​​‍‌​​‌​‌‌​‍‌​​‌​​​‌‍‌​​‌‌​​​‍‌‌​‌​​‌​‍‌​​‌​‌‌‌‍‌​​​‌​‌‌‍‌​​​‌​‌‌‍‌​​​‌‌‌‌‍‌‌​‌​​‌​‍‌​​​‌‌‌‌‍‌​​​‌‌​‌‍‌​​‌​​​​‍‌​​​​‌‌‌‍‌​​​​‌‌​‍‌‌​‌​​‌​‍‌​​‌​​​​‍‌​​‌​​​‌‍‌‌​‌​​‌​‍‌​​​‌​​​‍‌​​‌​‌‌​‍‌​​‌​​​‌‍‌​​‌‌​‌‌‍‌​​‌​​​​‍‌​​​‌​​​‍‌​​​‌‌​​‍‌‌​‌​​‌​‍‌​​​‌​​​‍‌​​‌​‌‌‌‍‌​​‌​‌‌​‍‌​​‌​​‌‌‍‌​​‌‌​‌​‍‌‌​‌​​‌​‍‌​​​‌​‌​‍‌​​​‌‌​​‍‌​​‌​‌‌​‍‌​​‌​​​‌‍‌​​‌‌​​​‍‌‌​‌​​‌​‍‌​​‌‌​​​‍‌​​‌​​​​‍‌‌​‌​​‌​‍‌​​‌‌​​​‍‌​​‌‌​‌​‍‌​​​‌​‌‌‍‌‌​‌​​‌​‍‌​​‌‌‌​​‍‌​​‌​​​​‍‌​​‌​​‌​‍‌​​‌​​‌​‍‌​​‌‌‌‌​‍‌​​‌​​​‌‍‌​​‌‌​‌‌‍‌‌​‌​​​‌‍‌​​‌​‌‌‌‍‌​​​‌​‌‌‍‌​​‌​​‌​‍‌​​‌​​‌‌

设置环境变量即可。(变量名需全小写)

对于 cmd.exe

set http_proxy=http://example.com:1080
set https_proxy=http://example.com:1080

对于 powershell.exe/pwsh.exe:

$env:http_proxy="http://example.com:1080"
$env:https_proxy="http://example.com:1080"

网上冲浪时发现一篇针对开发时代理环境设置的很好的文章,补充到这里:
https://keqingrong.cn/blog/2021-02-19-proxy-and-pac/

0

评论 (0)

取消