1、官网下载go语言安装包
2、服务器上安装go
将下载下来的安装包解压到/usr/local下
tar xf go1.12.1.linux-amd64.tar.gz -C /usr/local
3、配置全局变量
vim ~/.bashrc 最后一行加上下面配置 export GOPATH=/usr/local/go export PATH=$GOPATH/bin:$PATH
4、验证配置是否成功
[root@hz-jumpserver data]$ go version warning: GOPATH set to GOROOT (/usr/local/go) has no effect go version go1.12.1 linux/amd64
5、出现warning,配置PATH
export GOROOT=/usr/local/go
export GOPATH=$PATH:$GOROOT/bin
6、测试安装
[root@hz-jumpserver data]$ go version go version go1.12.1 linux/amd64