Setting up Go environment for Sublime
In this blog post, you can find answers to
- how to instal git in linux/mac
- how to configure git global settings in linux/mac
- how to install mercurial in linux/mac
- how to install homebrew
- how to install golang in linux/mac
- how to set PATH in linux/mac
- how to format go code on save in linux/mac
- how to install goimports in linux/mac
- how to install GoSublime in linux/mac
- how to configure GoSublime in linux/mac
To be able to use go get properly, we need git and mercurial
####Git installation
Install Git
linux
$ sudo apt-get install git
mac
$ brew install git
if you dont have brew, get it
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Set global config (if you need to)
$ git config --global user.name "Name Surname"
$ git config --global user.email "[email protected]"
####Mercurial Installation
Install Mercurial
linux
$ sudo apt-get install mercurial
mac
$ brew install mercurial
Install Go
Get go, this will install go to your /usr/local/go/ folder
$ curl -s https://storage.googleapis.com/golang/go1.3.linux-amd64.tar.gz | sudo tar -v -C /usr/local -xz
Or you can use other packages from http://golang.org/dl/
Set your path in .bashrc
PATH="/usr/local/go/bin:$PATH"
export GOPATH="/<projectroot>/go"
export GOROOT="/usr/local/go"
Install goimports, vet - This is realy useful for if you dont want to write your missing import paths, and formatting your code vet checks your code and warns about the Go style
$ go get code.google.com/p/go.tools/cmd/vet
$ go build code.google.com/p/go.tools/cmd/vet
$ go install code.google.com/p/go.tools/cmd/vet
goimports fixes import paths and formats code
$ go get code.google.com/p/go.tools/cmd/goimports
$ go build code.google.com/p/go.tools/cmd/goimports
$ go install code.google.com/p/go.tools/cmd/goimports
$ mv vet $GOROOT
$ mv goimports $GOROOT
####Sublime Installation