Mac 下安装 golang

1. 安装 golang

brew search go ## 搜素指定版本
brew install go ## 安装指定版本 go@xxx
1
2

2. 设置环境变量

# cat ~/.bash_profile
#GOROOT
export GOROOT="/usr/local/opt/go@1.11/libexec"

#GOPATH
export GOPATH=/Users/<Your_UserName>/go

#GOPATH root bin
export PATH=$PATH:$GOROOT/bin
1
2
3
4
5
6
7
8
9

查看环境变量

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/XXX/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/XXX/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go@1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go@1.11/libexec/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/w8/s4vpvhvd00j4s7jq_cvmmvm00000gn/T/go-build765739332=/tmp/go-build -gno-record-gcc-switches -fno-common"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

reference

访客IP ,您的网络 访问优先

本站是个人博客,书写大数据、数据科学等领域的原创学习记录,转载请注明出处

本站运行于 腾讯云 腾讯云