安装采用brew
然后配置环境
可以自己创建目录,结构中需要有 src bin pkg,bin目录需要添加到环境变量中。
vi /etc/profile
export GOROOT=/usr/local/go #设置为go安装的路径
export GOPATH=$HOME/gocode #默认安装包的路径
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
source /etc/profile
go get git上的代码时报错:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
可能是由于xcode问题造成的,可在终端中执行如下命令:xcode-select --install
安装完成后即可