mac安装go环境

https://golang.google.cn/dl/
 

sudo vim /etc/profile

11 export GOROOT=/usr/local/go

 12 export GOPATH=${GOROOT}/gopath

 13 export PATH=$PATH:${GOROOT}/bin

 14 export GO111MODULE=on

 15 export GOPROXY=https://goproxy.cn

 

source /etc/profile 

说明:
1. GOROOT 为go安装目录, 在mac下使用pkg包安装的, 目录为 /usr/loca/go

 

如果用go mod gopath 设置为/usr/local/go/gopath 

 

查看环境 

go env 

macdeMacBook-Pro:www mac$ go env 
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mac/Library/Caches/go-build"
GOENV="/Users/mac/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mac/Desktop/go_learn"
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/fc/4txmmczj6q92p6058h3w7t_80000gn/T/go-build984019761=/tmp/go-build -gno-record-gcc-switches -fno-common"

 

cd /Users/mac/Desktop/go_learn

macdeMacBook-Pro:go_learn mac$ go mod init brady

go: creating new go.mod: module brady

macdeMacBook-Pro:go_learn mac$ export GO111MODULE=on

 

mac安装go环境

上一篇:转 释一首美国民谣:沉默之音(The Sound Of Silence)


下一篇:bitnami redmine配置全过程