go-get使用代理

有的库使用go get无法访问。这里可以通过shadowsocks代理来实现。
首先要有个shadowsocks服务才可以。

windows

set http_proxy=http://localhost:1080
set https_proxy=http://localhost:1080

mac

export http_proxy=http://127.0.0.1:1080
export https_proxy=http://127.0.0.1:1080
下面这个不知道是否有用,如果上面不行,就试试下面的
export GIT_SSL_NO_VERIFY=true

下面是关于git的配置
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy

git是可以直接支持socks5代理的,如果只安装了shadowsocks,而不安Privoxy设置方法如下:

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

一个工具
brew install privoxy
nano /usr/local/etc/privoxy/config

找到# forward-socks5t / 127.0.0.1:9050 .在下面添加
forward / 127.0.0.1:1080

启动
sudo /usr/local/sbin/privoxy /usr/local/etc/privoxy/config

查看是否启动
ps aux | grep privoxy
查看端口监听是否成功:
netstat -an | grep 8118

export http_proxy=http://127.0.0.1:8118/
export https_proxy=http://127.0.0.1:8118/
然后执行go get

关闭Privoxy,首先查看privoxy的进程ID:
sudo killall privoxy
若以上方法都无法关闭Privoxy,请使用Privoxy提供的脚本进行关闭:
sudo /Applications/Privoxy/stopPrivoxy.sh

//=======
brew install proxychains-ng
配置文件:
/usr/local/etc/proxychains.conf
将socks4 127.0.0.1 9095改为
socks5 127.0.0.1 1080

proxychains4 go get -u google.golang.org/grpc

curl ip.cn
curl cip.cc
curl myip.ipip.net

proxy