Golang在Mac OS上的环境配置
安装Golang
==> Downloading https://homebrew.bintray.com/bottles/go-1.7.el_capitan.bottle.tar.gz ######################################################################## 100.0% ==> Pouring go-1.7.el_capitan.bottle.tar.gz ==> Caveats As of go 1.2,a valid GOPATH is required to use the `go get` command: https://golang.org/doc/code.html#GOPATH You may wish to add the GOROOT-based install location to your PATH: export PATH=$PATH:/usr/local/opt/go/libexec/bin ==> Summary ? /usr/local/Cellar/go/1.7: 6,435 files,250.6M 从提示中可以看出需要设置 配置GOPATH查看go 的环境变量设置的命令
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="" GORACE="" GOROOT="/usr/local/Cellar/go/1.7.6/libexec" GOTOOLDIR="/usr/local/Cellar/go/1.7.6/libexec/pkg/tool/darwin_amd64" GO15VENDOREXPERIMENT="" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common" CXX="clang++" CGO_ENABLED="1" 需要设置的环境变量包括: 在
在
export GOPATH=/usr/local/Cellar/go/1.7.6 export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN 使修改立刻生效:
再看下go的环境变量:
GOARCH="amd64" GOBIN="/usr/local/Cellar/go/1.7.6/bin" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/usr/local/Cellar/go/1.7.6" GORACE="" GOROOT="/usr/local/Cellar/go/1.7.6/libexec" GOTOOLDIR="/usr/local/Cellar/go/1.7.6/libexec/pkg/tool/darwin_amd64" GO15VENDOREXPERIMENT="" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common" CXX="clang++" CGO_ENABLED="1" 环境变量设置完成! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |