1.下载
https://golang.google.cn/dl/
wget -c -t 0 https://golang.google.cn/dl/go1.16.linux-amd64.tar.gz
2.验证文件完整性
sha256sum go1.16.linux-amd64.tar.gz
3.解压到/data1/usr/local/目录,并软链到/usr/local/go
(注:阿里云ECS系统盘空间不够,故用此法)
tar zxvf downloads/go1.16.linux-amd64.tar.gz -C /data1/usr/local/
ln -s /data1/usr/local/go /usr/local/go
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
source /etc/profile
https://www.jianshu.com/p/8f0646e3858c
https://studygolang.com/articles/15054
5.验证
go version
参考:
CentOS 7 安装Golang
https://www.jianshu.com/p/8f0646e3858c