yum install golang
#新建go目录作为项目目录
mkdir -p $HOME/go
#用cat的方法在尾部增加配置配置golang的 GOROOT GOPATH
cat >>$HOME/.bash_profile<<EOF
export GOROOT=/usr/lib/golang
export GOPATH=\$HOME/go
export PATH=\$PATH:\$GOROOT/bin
EOF
source $HOME/.bash_profile
go env
输出:
[giser@izbp182lz6444d7n8bnvx4z ipfs]$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/giser/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/giser/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/golang"
GOTMPDIR=""