centos安装golang语言,布置环境变量

1.下载golang安装包并解压到/usr/local/

cd /usr/src
wget https://golang.google.cn/dl/go1.18.linux-amd64.tar.gz
tar -xvf go1.18.linux-amd64.tar.gz -C /usr/local/

2.将/usr/local/go/bin添加到PATH路径当中

[root@VM-20-9-centos bin]# pwd
/usr/local/go/bin

3.编辑~/.bashrc

vim ~/.bashrc

4.在最后处添加以下内容:

# 设置GO语言路径
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

5.重启文件

source ~/.bashrc

6.输入go version查看是否安装成功

[root@VM-20-9-centos ~]# go version
go version go1.18 linux/amd64
posted @ 2022-05-10 18:59  安全兔  阅读(326)  评论(0编辑  收藏  举报