Centos7 安装go语言开发环境

1.安装

yum install  golang

2.配置环境变量

新建go目录作为项目目录

mkdir -p $HOME/go

用cat的方法在尾部增加配置配置golang的 GOROOT GOPATH

cat >>$HOME/.bash_profile<<EOF
export GOROOT=/usr/lib/golang
export GOPATH=\$HOME/golang
export PATH=\$PATH:\$GOROOT/bin
EOF

让配置生效

source $HOME/.bash_profile

3.检查下go的env环境变量

go env

输出

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/golang"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build349580051=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
    原文作者:CrazyCodeMonkey
    原文地址: https://www.jianshu.com/p/00d048eb9854
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞