centos系统配置go环境
安装包下载地址:https://golang.google.cn/dl/
安装参考文档:https://c.biancheng.net/view/3993.html
1.安装Go语言开发包
# wget https://golang.google.cn/dl/go1.21.4.linux-amd64.tar.gz
# tar xf go1.21.4.linux-amd64.tar.gz -C /usr/local/
2.配置环境变量
# vim /etc/profile.d/go.sh
#!/bin/bash
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOBIN
export GOPATH=/go
export GO111MODULE=auto
export GOPROXY=https://goproxy.cn,direct
# source /etc/profile.d/go.sh
3.验证安装
# go env
# go env
GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/root/tour/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3156364701=/tmp/go-build -gno-record-gcc-switches'