美文网首页
Golang.org/x目录被Blocked的解决方案

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

作者: 陈哈哈GO | 来源:发表于2019-02-16 15:11 被阅读7次

在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

其它库以相同方式处理。

相关文章

网友评论

      本文标题:Golang.org/x目录被Blocked的解决方案

      本文链接:https://www.haomeiwen.com/subject/rvnbeqtx.html