Centos使用yum安装Go(Golang)时报错:No package golang available.

直接使用yum install golang

[root@master app]# yum install golang
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
没有可用软件包 golang。

解决办法1:

先添加源,再使用命令行安装。添加源的方式如下:

								Install on CentOS:
								Current version: 1.12.5
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.12.5
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

来源:https://go-repo.io/

解决办法2:

先安装epel:yum install epel-release
然后再安装golang:yum install golang
go version 查看安装的版本

你可能感兴趣的:(Linux)