Download go language source code
wget https://golang.google.cn/dl/go1.16.6.linux-amd64.tar.gz
Decompression: tar -zxvf go1.16.6.linux-amd64.tar.gz
Enter the bin directory
cd /usr/local/go/bin
./go version
output
go version go1.16.6 linux/amd64
Set GOROOT and GOPATH
vim /etc/profile
write at the end
export GOPATH=/home/workspace
export GOROOT=/usr/local/go
PATH=$GOROOT/bin:$PATH
Where workspace is your working directory
source /etc/profile
Make the environment variable take effect immediately