代码改变世界

mac home brew install go

2017-08-31 13:36  faunjoe88  阅读(803)  评论(0编辑  收藏  举报

mac利器home brew安装Go

首先你得需要安装home brew和ruby环境(因为home brew依赖ruby) 

如果没有请自行到链接安装

准备好之后就开始安装go

brew update && brew upgrade
brew install git
brew install mercurial
brew install go

安转go之后还需要配置环境变量

vim ~/.bash_profile  or vim ~/.bash_profile
#GOROOT
export GOROOT=/usr/local/Cellar/go/1.7.4/libexec

#GOPATH
export GOPATH=$HOME/GoLang

#GOPATH bin
export PATH=$PATH:$GOPATH/bin

#GOPATH root bin
export PATH=$PATH:$GOROOT/bin
source ~/.bash_profile or source ~/.bash_profile

ok go环境配置完毕,接下来输入go env即可看到go的详细信息

bogon:~ faunjoe$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/faunjoe/work/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x4/zr94mx8s1n35ysp_rcl6dk7m0000gn/T/go-build768068792=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"