环境:
系统 Mac OX
shadowsockes 作为代理
在安装 go 或者使用 golang包时往往需要出现错误 无法链接到google服务器,添加一层代理(git)往往解决不了问题,这时候就需要做两层代理,一层git代理,一层系统代理(在配置文件bash或zsh中设置)
#shadowsockes 默认使用端口为1080
Cloning into '/Users/Miller/Library/Caches/Homebrew/go@1.9--gotools--git'...
fatal: unable to access 'https://go.googlesource.com/tools.git/': Failed to connect to go.googlesource.com port 443: Operation timed out
1、git层代理
#设置
git config --global http.proxy "localhost:1080"
#取消
git config --global --unset http.proxy
2、系统层代理
#已~/.zshrc为例添加内容如下
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080
source ~/.zshrc
brew install go@1.9
echo 'export PATH="/usr/local/opt/go@1.9/bin:$PATH"' >> ~/.zshrc