Golang.org/x目录被Blocked的解决方案

2019-02-16  本文已影响7人  陈哈哈GO

在Go开发中,经常有大量项目依赖golang.org/x包,但这个源码包被储放在万恶的国外资本势力的服务器上,国内开发人员想要使用需要一翻动作。
golang团队将他们的代码镜像在Github上,因此,我们可以将golang.org/x使用到的包,统统下载在我们开发环境的 $GOPATH/src/golang.org/x 目录,编译项目时就可以直接使用本地依赖。

首先,在 $GOPATH 目录中创建 golang.org/x 目录:

$ mkdir -p $GOPATH/src/golang.org/x

然后把x的几个包clone下来:

$ cd $GOPATH/src/golang.org/x
# Clone 常用和几个库:
$ git clone --depth=1 https://github.com/golang/tools.git
$ git clone --depth=1 https://github.com/golang/sys.git
$ git clone --depth=1 https://github.com/golang/crypto.git
$ git clone --depth=1 https://github.com/golang/text.git
$ git clone --depth=1 https://github.com/golang/net.git

其它库以相同方式处理。

上一篇 下一篇

猜你喜欢

热点阅读