环境:
OS:Centos 7
1.下载
下载地址为 https://studygolang.com/dl
我这里下载的是go1.13.3.linux-amd64.tar.gz
2.安装
我这里将golang安装到opt目录下
[root@oracle-9e96168-prd soft]# mkdir -p /opt/golang
[root@oracle-9e96168-prd soft]#tar -C /opt/golang -zxvf go1.13.3.linux-amd64.tar.gz
3.添加环境变量
在相应的用户下添加环境变量,修改.bash_profile即可
[yeemiao@yw-backup-fa24dbb-test ~]$ more .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export GOROOT=/opt/golang/go
PATH=$GOROOT/bin:$PATH:$HOME/.local/bin:$HOME/bin
export PATH
4.验证
重新登录后运行
[yeemiao@yeemiao-oracle-9e96168-prd sendmail]$ go version
go version go1.13.3 linux/amd64