yum安装go语言的方法:1、执行“yum -y install golang”命令安装go;2、编辑profile文件,配置环境变量;3、执行“source /etc/profile”命令即可。
本文操作环境:centos 7系统、go 1.11.2、thinkpad t480电脑。
具体步骤:
1、安装golang
yum -y install golang
2、环境配置
1)打开profile文件
vi /etc/profile
2)添加环境变量 在文件后面追加如下文本:
# gorootexport goroot=/usr/lib/golang# gopathexport gopath=/root/go/# gopath binexport path=$path:$goroot/bin:$gopath/bin
需要立即生效,在终端执行如下命令:
source /etc/profile
再次查看:
$ go env
goarch="amd64"gobin=""gocache="/root/.cache/go-build"goexe=""goflags=""gohostarch="amd64"gohostos="linux"goos="linux"gopath="/root/go"goproxy=""gorace=""goroot="/usr/lib/golang"gotmpdir=""gotooldir="/usr/lib/golang/pkg/tool/linux_amd64"gccgo="gccgo"cc="gcc"cxx="g++"cgo_enabled="1"gomod=""cgo_cflags="-g -o2"cgo_cppflags=""cgo_cxxflags="-g -o2"cgo_fflags="-g -o2"cgo_ldflags="-g -o2"pkg_config="pkg-config"gogccflags="-fpic -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build417743789=/tmp/go-build -gno-record-gcc-switches"
至此,go语言已经安装好了。
相关推荐:golang教程
以上就是yum怎么安装go语言的详细内容。