1.下载golang安装包
去https://studygolang.com/dl最新的安装包
wget https://studygolang.com/dl/golang/go1.17.7.linux-amd64.tar.gz
2.解压至/usr/local文件夹
tar -C /usr/local -xzf go1.15.5.linux-amd64.tar.gz
2.配置环境变量vim /etc/profile
export GOROOT=/usr/local/go #设置为go安装的路径
export GOPATH=$HOME/go #默认安装包的路径
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
source /etc/profile使修改生效.
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct