下载安装包
go下载:
下载地址:https://golang.google.cn/dl/
创建安装目录移动并解压到安装目录
[root@server01 ~]# mkdir -p ~/support/gopath [root@server01 ~]# mv go1.15.6.linux-amd64.tar.gz ~/support [root@server01 ~]# cd support/ [root@server01 support]# tar xf go1.15.6.linux-amd64.tar.gz
添加环境变量
[root@server01 ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
#go
export GOROOT=~/support/go
export GOPATH=~/support/gopath
export PATH=${GOROOT}/bin:$PATH
export PATH=${GOPATH}/bin:$PATH
source ~/.bash_profile
查看环境变量是否生效
[root@server01 ~]# source ~/.bash_profile [root@server01 ~]# go version go version go1.15.6 linux/amd64
