热门搜索 :
考研考公
您的当前位置:首页正文

下载 golang.org/x 包出错不用代理的解决办法

来源:东饰资讯网

由于国内的网络环境导致在下载依赖 golang.org/x 下的包时一般会出错。
比如 :

一般你可以通过设置代理,如果代理使用了 pac 模式的话,可能需要编辑下 pac 文件。下面要介绍的是一种不代理的解决办法。

原理

  1. 当我们使用 import "golang.org/x/tools/go/buildutil" 导入包时,其实导入的是$GOPATH/src/golang.org/x/tools/go/buildutil目录的包。

实例

比如先切换到 $GOPATH 的 src 目录,cd $GOPATH/src,然后按需要下载:

  1. git clone --depth 1 golang.org/x/tools
  2. git clone --depth 1 golang.org/x/lint
  3. git clone --depth 1 golang.org/x/net
  4. git clone --depth 1 golang.org/x/sys
  5. git clone --depth 1 golang.org/x/crypto
  6. git clone --depth 1 golang.org/x/text
  7. git clone --depth 1 golang.org/x/image
  8. git clone --depth 1 golang.org/x/oauth2
Top