go的默认安装路径是 /usr/local/go
编辑
vim ~/.bash_profile
配置参数
export GOROOT=/usr/local/go export GOPATH=/Users/wangteng/go export GOBIN=$GOROOT/bin export PATH=$PATH:$GOBIN
配置生效
source ~/.bash_profile
wangtengdeMacBook-Pro:go wangteng$ go env //查看环境
GO111MODULE=""
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCACHE="/Users/wangteng/Library/Caches/go-build"
GOENV="/Users/wangteng/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/wangteng/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io"
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=/tmp/go-build207785438=/tmp/go-build -gno-record-gcc-switches -fno-common"