一下载golang源码包:
现在地址: https://golang.google.cn/dl/
go1.11.2.linux-amd64.tar.gz
二Centos系统版本信息:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
查看内核版本命令:
[root@localhost ~]# cat /proc/version
inux version 3.10.0-862.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Fri Apr 20 16:44:24 UTC 2018
[root@localhost ~]#
[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64
三安装配置golang语言环境
注意:用root账号安装
1 将下载的二进制包解压至 /opt/app/目录。
依次执行如下命令:
cd /opt
mkdir app
cd app
tar -C /opt/app/ -zxvf go1.11.2.linux-amd64.tar.gz
2 新建GOPATH目录
cd /opt
mkdir goWork
3 将 /opt/app/go/bin 目录添加至PATH环境变量:
在/etc/profile文件尾部添加:
vim /etc/profile
export GOROOT=/opt/app/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=/opt/goWork
:wq保存
使其生效:source /etc/profile
4 查看是否配置成功
执行命令:go version
go version go1.11.2 linux/amd64
执行命令:go env
GOARCH="amd64"
GOBIN="/opt/app/go/bin"
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/goWork"
GOPROXY=""
GORACE=""
GOROOT="/opt/app/go"
GOTMPDIR=""
GOTOOLDIR="/opt/app/go/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build871203888=/tmp/go-build -gno-record-gcc-switches"
转载于:https://blog.51cto.com/1693346/2344553