37
go get命令使用socket代理
source link: http://www.hi-roy.com/2018/10/12/go-get命令使用socket代理/?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
由于某些不可描述的原因,国内使用 go get
命令安装某些包的时候会超时导致失败,比如 net
包、 sys
包、 tools
包等。第一种解决办法就是自己从git上下载后添加链接到 GOPATH
中,比如:
git clone https://github.com/golang/net.git $GOPATH/src/github.com/golang/net git clone https://github.com/golang/sys.git $GOPATH/src/github.com/golang/sys git clone https://github.com/golang/tools.git $GOPATH/src/github.com/golang/tools ln -s $GOPATH/src/github.com/golang $GOPATH/src/golang.org/ cd $GOPATH/src/golang.org/ && mv golang x
另外就是使用代理,网上大多是使用http代理,这里记录下如何使用socket代理。 go get
命令其实也是利用了 git
命令进行下载,不过下载后会自动编译安装,所以首先设置git的代理:
git config --global http.proxy socks5://127.0.0.1:7070
然后
http_proxy=socks5://127.0.0.1:7070 go get xxxx
就可以了。
恢复的话可以重置git配置:
git config --global --unset http.proxy
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK