下载golang二进制包

地址:

1
https://golang.google.cn/dl/

解压

1
tar xf go1.13.3.linux-amd64.tar.gz -C /usr/local/

配置环境变量

注意:这一步非常重要

1
# tail -5 /etc/profile
2
3
    export GOROOT=/usr/local/go
4
    export PATH=$PATH:$GOROOT/bin
5
    export GOPATH=$HOME/golang/gopath/
6
    export GOPATH=$HOME/golang/gopath/
7
    export PATH=$GOPATH/bin:$PATH