本方法在centos系列系统中实用,其余系统暂没有测试过!
- 下载go的tar文件并解压
cd /opt && wget https://go.dev/dl/go1.17.5.linux-amd64.tar.gz
tar zxvf go1.17.5.linux-amd64.tar.gz
[ -f go1.17.5.linux-amd64.tar.gz ] && rm go1.17.5.linux-amd64.tar.gz -rf
- 设置环境变量
echo "" >> /etc/profile
echo "##go 环境变量设置" >> /etc/profile
echo "export GOPATH=/opt/go" >> /etc/profile
echo "export PATH=\$PATH:\$GOPATH/bin" >> /etc/profile
echo 'export GOPROXY="https://goproxy.cn"' >> /etc/profile
echo "export GO111MODULE=on" >> /etc/profile
source /etc/profile