Golang安装示例

Github-blog
CSDN-blog

为了安装Go 1.x(x≥5),需要先安装 Go1.4到 G O R O O T B O O T S T R A P GOROOT_BOOTSTRAP 是 $HOME/go1.4。我们其作为启动的基础版本来编译工具链。

go1.4安装

wget https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.tar.gz
tar -xf go1.4-bootstrap-20170531.tar.gz  
cd go/src  
./make.bash  

//成功后会出现如下信息  
Installed Go for linux/amd64 in /home/go  
Installed commands in /home/go/bin  
//重命名1.4文件夹,并添加GOROOT_BOOTSTRAP环境变量
mv go go1.4  
export GOROOT_BOOTSTRAP=/home/go1.4   

go1.10安装

wget https://storage.googleapis.com/golang/go1.10.1.src.tar.gz  
tar -xf go1.10.1.src.tar.gz  
cd go/src  
./all.bash  

设置环境变量

export PATH=$PATH:/home/go1.10/bin   
//检查安装是否成功
root@xftony:~# go version
go version go1.10.1 linux/amd64

常见错误

##### Building Go bootstrap tool.
cmd/dist
ERROR: Cannot find /root/go1.4/bin/go.
Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.

解决方法:安装go1.4, 并添加GOROOT_BOOTSTRAP环境变量 export GOROOT_BOOTSTRAP=/home/go1.4/, 即本文第一步安装go1.4的操作

Github-blog
CSDN-blog

猜你喜欢

转载自blog.csdn.net/xftony/article/details/80160151