The purpose of this test drive is to understand the setup and capabilities of the Go programming language. Before wasting your time, take a look at the resources used to fuel this test drive.
To easily install, manage, and work with multiple Go versions, install Go Version Manager with these instructions.
Prepend to your ~/.bash_profile
:
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
Reload your profile:
$ source ~/.bash_profile
Install latest Go version:
$ gvm install go1.4
Set as default:
$ gvm use go1.4 --default
To lint your code, install Golint.
$ go get -u github.com/golang/lint/golint
Append to your ~/.vimrc
to print style mistakes after a save:
" https://github.com/golang/lint#vim
set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
autocmd BufWritePost,FileWritePost *.go execute 'Lint' | cwindow
To view your program documentation, install GoDoc.
$ go get -u golang.org/x/tools/cmd/godoc
Refer to the Godoc: documenting Go code blog post for some background and comment convention.
For other awesome tools, check out Go Tools.
$ go run src/testdrive/main.go
Compile your source code using build:
$ go build -o bin/testdrive src/testdrive/main.go
Run:
$ ./bin/testdrive
- Basics - Importing packages, variables, functions, etc.