一、下载
去Golang官网
)下载需要的版本,这里直接下载苹果版的pkg
二、 安装
直接双击运行pkg,在弹出的安装页面直接安装就行了。
三、测试
输入go version
测试go版本。用go env
可以查看go环境的变量
默认安装的
GOROOT=”/usr/local/go”
GOPATH=”/Users/admin/go”
> go version
go version go1.14.3 darwin/amd64
>go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/admin/Library/Caches/go-build"
GOENV="/Users/admin/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/admin/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
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/f0/hzbq_2x975d0fq612z4tgy8c0000gn/T/go-build027263215=/tmp/go-build -gno-record-gcc-switches -fno-common"