临时代理脚本
在系统环境变量的PATH 路径下建立一个脚本文件,并命名为 proxy。这里使用 gfwpress工具作代理(linux下请参考 linux 下翻墙工具(GFW.PRESS))。如果是 shadowsocks需要通过额外的代理工具转换成 http代理,请移步。
windows 下使用
#!/bin/bash
# export {http,https,ftp}_proxy='http://127.0.0.1:3128'
http_proxy=http://127.0.0.1:3128 https_proxy=http://127.0.0.1:3128 $*
linux 下使用
#!/bin/bash
export http_proxy=http://127.0.0.1:3143
export https_proxy=http://127.0.0.1:3143
export no_proxy="m10.music.126.net,10.*.*.*,192.168.*.*,*.local,localhost,127.0.0.1"
$*
* 简单测试一下
$ prxoy go get golang.org/x/net
拓展
设置git代理(因为 github本来就能访问,代理实际上只能让网速变快点)
如果使用免费的翻墙工具 gfwpress 作代理,默认代理 http到 3128端口:
git config --global http.proxy http://127.0.0.1:3128 |
git config --global https.proxy http://127.0.0.1:3128 |
如果使用 shadowsocks,默认监听 1080端口:
git config --global http.proxy 'socks5://127.0.0.1:1080' |
git config --global https.proxy 'socks5://127.0.0.1:1080' |
取消 git代理:
git config --global --unset http.proxy |
git config --global --unset https.proxy |
其他方法
1)直接下载第三方包
3)使用替代方案(对 golang.org/x/... 有效)
** 由于golang.org/x/net 包被墙导致无法安装,可以尝试使用下面的命令解决
```
$ mkdir -p $GOPATH/src/golang.org/x/
$ cd $GOPATH/src/golang.org/x/
$ git clone https://github.com/golang/net.git net