1.下载golang安装包
wget https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz
2.解压至/usr/local文件夹
tar -C /usr/local -xzf go1.12.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使修改生效.
3.测试结果
创建文件夹
mkdir -p /root/go/src