linux 安装/卸载go环境(基于centos8)
安装
下载go的安装包
Golang官网下载地址:https://golang.org/dl/
将安装包解压放到到usr/local中,并解压
cd /usr/local
tar -zxvf go1.11.5.linux-amd64.tar.gz
将/usr/local/go/bin添加到环境变量中
vim /etc/profile
# 在最后一行添加
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
# 保存退出后source一下(vim 的使用方法可以自己搜索一下)
source /etc/profile
执行go -version查看是否安装成功
[root@k8s-master-lb ~]# go version
go version go1.19.1 linux/amd64
卸载
查看GOROOT地址
[root@k8s-master-lb ~]# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build888858165=/tmp/go-build -gno-record-gcc-switches"
[root@k8s-master-lb ~]#
删除GOROOT目录,卸载完成,即可重新安装
rm -rf /usr/local/go