源码安装Golang
下载
Golang
源码
wget https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz
解压源码到
/usr/local
目录
tar -C /usr/local -xzf go1.14.1.linux-amd64.tar.gz
配置
Golang
环境变量
在配置文件/etc/profile
最后加入设置
Golang
下载代理
go env -w GOPROXY=https://goproxy.cn,direct
export GOROOT=/usr/local/go # 设置为go安装的路径
export GOPATH=/root/code/go # go get下载的东西都会放到这里
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
是配置文件生效source /etc/profile
- 查看
go env
环境变量
[root@quanbu-qa-22-19 ~]# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/code/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build591268624=/tmp/go-build -gno-record-gcc-switches"
有疑问加站长微信联系(非本文作者)