google go-tour安装

由于
go get code.google.com/p/go-tour/gotour

报错:
# cd .; hg clone -U https://code.google.com/p/go-tour /usr/home/huaying/go/src/pkg/code.google.com/p/go-tour
abort: error: EOF occurred in violation of protocol
package code.google.com/p/go-tour/gotour: exit status 255

还有其它各种错误,总之无法使用go get 安装
只能手动下载安装(已安装Mercurial)
hg clone https://code.google.com/p/go-tour/
cp -r go-tour $GOROOT/src/pkg/code.google.com/p
cd $GOROOT/src/pkg/code.google.com/p/go-tour/go-tour
go install ./
ls -lrt $GOROOT/bin

可以看到有一个gotour,直接运行即可

由于国情的原因,code.google.com不能直接访问,hg通过在.hgrc中设置http_proxy可能也会报错,也有些同行是成功的,反正我是通不过,只能手工安装。
通过链接下载[url="https://code.google.com/p/go-tour/source/browse/"]go-tour[/url]的代码zip和tar.gz包,解压缩到$GOPATH/src/code.google.com目录下。
cd $GOPATH/src/code.google.com/p/go-tour/gotour
go install ./

此时会报一些错,根据每个人的环境会有所不同,根据提示安装所需要的包
在[url="https://github.com/golang"]github/golang[/url]中有对应的包,如net和tools包用以下两个命令
go get github.com/golang/net
go get github.com/golang/tools

在$GOPATH/src/github.com/golang 下会找到刚才下载的两个包
但安装go-tour时,需要的目录是[color=blue][b]src/golang.org/x/net[/b][/color]
此时需要正确配置目录,用链接和复制的方式都可以
我是用的链接的方式
mkdir -p $GOPATH/src/golang.org/x
ln -s $GOPATH/src/github.com/golang/net $GOROOT/src/golang.org/x
ln -s $GOPATH/src/github.com/golang/tools $GOPATH/src/golang.org/x

也可以直接
ln -s $GOPATH/src/github.com/golang $GOROOT/src/golang.org/x

再用 go install 安转就能正确安装,在$GOROOT/bin目录下有个gotour文件,直接运行即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值