天天看点

三大步完成A-Tour-of-Go安装

发现运行官方给的命令:

$go get golang.org/x/tour
           

连续几次,一直报连接超时,无法下载包。不过因为 golang.org/x/xxx 这类包托管在 github.com/golang,所以我们可以从github安装,只是要注意几个包的依赖关系。

步骤是:

1、建立好目录结构:

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

2、下载相关的包

$git clone https://github.com/golang/net
$git clone https://github.com/golang/tools
$git clone https://github.com/golang/tour
           

3、安装和运行

$go install github.com/golang/tour
$cd $GOPATH/bin
$tour