1.下载go二进制包
由于go的官网有墙,在这里提供go1.14版本的go二进制包以提供进行下载
链接:https://pan.baidu.com/s/1ToPmrzbRfjeI0-I7zDBt-Q
提取码:6bvy
或者
wget https://golang.google.cn/dl/go1.14.4.linux-amd64.tar.gz
2.安装go语言
1.首先卸载原先的go,然后安装并设置安装路径PATH,最后go env有输出则成功。
rm -rf /usr/local/go
sudo tar -xzf go1.14.4.linux-amd64.tar.gz -C /usr/local
sudo ln -s /usr/local/go/bin/* /usr/bin/
go version
mkdir -p $HOME/go-work/src
mkdir -p $HOME/go-work/pkg
mkdir -p $HOME/go-work/bin
echo "export GOROOT=/usr/local/go">>$HOME/.bashrc
echo "export GOPATH=$HOME/go-work">>$HOME/.bashrc
echo "export PATH=$PATH:$GOROOT/bin:$GOPATH/bin">>$HOME/.bashrc
source $HOME/.bashrc
go env