1.下载go1.4-bootstrap
wget https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz
tar -zxvf go1.4-bootstrap-20171003.tar.gz
2.配置GOROOT_BOOTSTRAP
vim /etc/profile.d/go1.4-bootstrap.sh
export GOROOT_BOOTSTRAP=/usr/local/src/go1.4-bootstrap
export CGO_ENABLED=0
source /etc/profile
3.安装go1.4-bootstrap
cd go1.4-bootstrap/src
./make.bash
4.源码安装go
wget https://golang.google.cn/dl/go1.16.2.src.tar.gz
tar -zxvf go1.16.2.src.tar.gz
cd go/src
./all.bash
5. 配置环境变量
vim /etc/profile.d/go.sh
export $GOROOT=/usr/local/soft/go
export $GOPATH=/workspace/go
export PATH=$PATH:$GOROOT/bin
export GOPROXY=https://goproxy.cn,direct
有疑问加站长微信联系(非本文作者)