参考: https://code.google.com/p/go-wiki/wiki/GoGetTools
Installing Version Control Tools for go get
The go get fetching of source code is done by using one of the following tools expected to be found on your system:
- svn – Subversion, download at: http://subversion.apache.org/packages.html
- hg – Mercurial, download at http://mercurial.selenic.com/wiki/Download
- git – Git, download at http://git-scm.com/downloads
- bzr – Bazaar, download at http://wiki.bazaar.canonical.com/Download
Refer GoGetProxyConfig for setting proxies for these tools.
如: 安装 code.google.com/p/goprotobuf/proto :
go get code.google.com/p/goprotobuf/proto
但是,这里需要hg这个命令,可以使用yum安装:
yum install *mercurial*
而对于github上的go包,需要先安装git,然后使用go get, 例如:
go get github.com/golang/groupcache
代码会自动安装在GOPATH 下的src目录中
补充说明:(其实这个写在前面更好)
go get是可以自动管理依赖的,比如,上面的groupcache以来proto,如果先安装hg这个命令的话,直接安装groupcache时,是可以自动安装proto的; 不过如果不太幸运的话,有些包会安装失败的,下图就是一个例子: