Have Ubuntu 14.04 installed on the VM I use as a programming/testing environment.
Golang packages in Ubuntu 14.04 repo are a bit old:
dpkg -l | grep golang ii golang 2:1.3.3-1ubuntu4~ubuntu14.04.1 all Go programming language compiler - metapackage ii golang-doc 2:1.3.3-1ubuntu4~ubuntu14.04.1 all Go programming language compiler - documentation ii golang-go 2:1.3.3-1ubuntu4~ubuntu14.04.1 amd64 Go programming language comp ...
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
In order to compile Go 1.5+, make sure Go 1.4 is installed first. Go 1.5+ removed the C compilers from the toolchain and replaced them with one written in Go. Obviously, this creates a bootstrapping problem if you don’t already have a working Go install. In order to install 1.6.3:
gvm install go1.4 -B gvm use go1.4 export GOROOT_BOOTSTRAP=$GOROOT gvm install go1.6.3
gofmt, golint, govet
A handful of useful tools to keep the code neat and correct.
Gofmt formats Go programs. It uses tabs (width = 8) for indentation and blanks for alignment.
Without an explicit path, it processes the standard input. Given a file, it operates on that file; given a directory, it operates on all .go files in that directory, recursively. (Files starting with a period are ignored.) By default, gofmt prints the reformatted sources to standard output.
Gofmt comes with vanilla Golang so no installation required. Example usage:
Golint is a linter for Go source code.
go get -u github.com/golang/lint/golint
cd <project_dir> && golint ./...
Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string. Vet uses heuristics that do not guarantee all reports are genuine problems, but it can find error s not caught by the compilers. Comes out of box as well.
cd <project_dir> && go vet ./...