1.下载
https://golang.google.cn/dl/
2.验证文件完整性
3.解压到/data1/usr/local/目录,并软链到/usr/local/go
(注:阿里云ECS系统盘空间不够,故用此法)
4.配置环境变量
cat <<EOT >> /etc/profile
export GOROOT=/usr/local/go
export GOPATH=/data1/workspace/go/go_path
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
EOT
或者:
echo -e "export GOROOT=/usr/local/go\nexport GOPATH=/data1/workspace/go/go_path\nexport GOBIN=$GOPATH/bin\nexport PATH=$PATH:$GOROOT/bin:$GOPATH/bin" >> /etc/profile
5.验证
参考:
CentOS 7 安装Golang
https://www.jianshu.com/p/8f0646e3858c
有疑问加站长微信联系(非本文作者)