下载安装包
国外的
国内的
安装
mac os
- 直接点击
go1.12.7.darwin-amd64.pkg
,进入图形界面安装。 在
~/.zshrc
中,添加环境变量(如果是别的sh,请在别的sh中配置)#GOROOT export GOROOT=/usr/local/go/ #GOPATH go项目路径 export GOPATH=$HOME/workspace/project #GOPATH bin export PATH=$PATH:$GOPATH/bin #GOPATH root bin export PATH=$PATH:$GOROOT/bin
source ~/.zshrc
验证
# go version go version go1.12.7 darwin/amd64 # go env GOARCH="amd64" GOBIN="" GOCACHE="/Users/manshu/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/manshu/workspace/project" GOPROXY="https://goproxy.io" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" 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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wp/w879p9h15x983cgrs5cz25rc0000gn/T/go-build153405912=/tmp/go-build -gno-record-gcc-switches -fno-common"
linux
- 解压
tar xzvf go1.12.7.linux-amd64.tar.gz -C /usr/lib/
在
~/.bashrc
中,添加环境变量(如果是别的sh,请在别的sh中配置#GOROOT export GOROOT=/usr/lib/go #GOPATH go项目路径 export GOPATH=/root/gocode #GOPATH bin export PATH=$PATH:$GOPATH/bin #GOPATH root bin export PATH=$PATH:$GOROOT/bin
source ~/.bashrc
验证
[root@compute84 bin]# go version go version go1.12.7 linux/amd64 [root@compute84 bin]# [root@compute84 bin]# go env GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/root/gocode" GOPROXY="https://goproxy.io" GORACE="" GOROOT="/usr/lib/go" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GCCGO="gccgo" 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-build670179021=/tmp/go-build -gno-record-gcc-switches"