mac安装go环境

本小妞迷上赌 提交于 2020-07-25 06:09:32
下载pkg文件
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

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!