Go语言学习 - 配置开发环境(IntelliJ IDEA 14 For Mac OS 10.10)

1、安装 Go-Lang

1
2
$ brew install go
$ go version


2、配置环境变量

1
2
3
$ vim ~/.zshrc
export GOROOT=/usr/local/opt/go/libexec
export GOPATH=$HOME/.go


3、Intellij IDEA 安装 go-lang-idea-plugin

  • IntelliJ IDEA -> Preferences -> Plugins -> Browse Repositories
  • 搜索golang,点击 “Install plugin”
  • 安装完重启

go-lang-idea-plugin会提示配置GOROOT,GOPATH。。。搜了各种资料,需要这样配置一下:

1
2
3
4
vim .zshrc
launchctl setenv GOROOT /usr/local/opt/go/libexec
launchctl setenv GOBIN /usr/local/opt/go/libexec/bin
launchctl setenv GOPATH /ROOT/www/go