标签 Go 下的文章

1.完全卸载golang
查看路径在哪里:

which go

root 权限下删除

rm -rf /usr/local/go

2.安装golang
下载golang包

wget https://golang.google.cn/dl/go1.16.linux-amd64.tar.gz

解压到usr/local下

tar -C /usr/local/ -zxvf go1.16.linux-amd64.tar.gz

修改配置文件(系统配置为/etc/profile,用户配置为~/.profile),这里就修改系统配置

sudo vim /etc/profile

在文件最后加上两行(如果有旧版本的go配置就不用加,或者要修改路径)

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

执行使配置文件生效

source /etc/profile

查看go版本

go version

本来准备直接yum install golang或者yum install go, 执行命名后,发现没有这个包。于是只能先添加源,然后在使用命令行安装了。

Install on CentOS: 
Current version: 1.11
rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
yum install golang
        


Install on Fedora: 
Current version: 1.11
rpm --import https://mirror.go-repo.io/fedora/RPM-GPG-KEY-GO-REPO
curl -s https://mirror.go-repo.io/fedora/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
yum install golang
        


Example $GOPATH setup:
mkdir -p ~/go/{bin,pkg,src}
echo 'export GOPATH="$HOME/go"' >> ~/.bashrc
echo 'export PATH="$PATH:${GOPATH//://bin:}/bin"' >> ~/.bashrc
        


Unstable (Pre-release) Packages
Current version: 1.11rc2 

CentOS:
rpm --import https://mirror.go-repo.io/centos-unstable/RPM-GPG-KEY-GO-REPO
curl -s https://mirror.go-repo.io/centos-unstable/go-repo-unstable.repo | tee /etc/yum.repos.d/go-repo-unstable.repo
yum install golang
        

Fedora:
rpm --import https://mirror.go-repo.io/fedora-unstable/RPM-GPG-KEY-GO-REPO
curl -s https://mirror.go-repo.io/fedora-unstable/go-repo-unstable.repo | tee /etc/yum.repos.d/go-repo-unstable.repo
yum install golang