Mac上go環境配置
使用Homebrew 安裝go語言sdk
brew install go
==> Downloading https://homebrew.bintray.com/bottles/go-1.5.1.el_capitan.bottle.
Already downloaded: /Library/Caches/Homebrew/go-1.5.1.el_capitan.bottle.tar.gz
==> Pouring go-1.5.1.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.5.1: 5330 files, 273M
配置GOPATH
查看go 的環境變量設置
go env
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="" GORACE="" GOROOT="/usr/local/Cellar/go/1.5.1/libexec" GOTOOLDIR="/usr/local/Cellar/go/1.5.1/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"
需要設置環境變量GOPATH
,GOBIN
以及把GOBIN加入到PATH
中
在fishshell設置GOPATH
set -gx GOPATH /usr/local/Cellar/go/1.5.1
vim .bash_profile
export GOPATH=/usr/local/Cellar/go/1.5.1 export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN
source .bash_profile
再看下go的環境變量
go env
GOARCH="amd64" GOBIN="/usr/local/Cellar/go/1.5.1/bin" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/usr/local/Cellar/go/1.5.1" GORACE="" GOROOT="/usr/local/Cellar/go/1.5.1/libexec" GOTOOLDIR="/usr/local/Cellar/go/1.5.1/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"
環境變量設置成功!
本文由用戶 mwrx6905 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!