Golang Adventures

The beginning of my GoLang discoveryies, starting with setting up Spacemacs IDE

Starting with Go Language

As with most languages, I start with trying to find a good method for setting up a project, linters, and some examples of TDD. I did not realize at the time what the whole ideal structre was for the Go language, which caused me to search for something that did not exist: the perfect project template.

The Setup

There are a couple of things you want to setup:

  1. the GOPATH which points to your go binary you have downloaded
  2. your PATH that points to $(go env GOPATH)/bin which will allow you to use binaries that have been installed by go get ...
  3. (optionally) GOROOT which is where your go world lives

Still using my latest choice of editors Spacemacs I have found, I wanted to see what layers are available. The Go Layer has a nice list of things to do:

# run this after installing go, and setting your paths
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v golang.org/x/tools/cmd/goimports

decide if you want to go with the stable version or the latest version of the gometalinter

(stable)

# stable, binary is gometalinter.v1
go get -u gopkg.in/alecthomas/gometalinter.v1
gometalinter.v1 --install --update
# latest, binary is gometalinter
go get -u -v github.com/alecthomas/gometalinter
gometalinter --install --update

Add stuff to your .spacemacs file for customization in your layers

   dotspacemacs-configuration-layers
   '(
     ruby
     python
     go
     (go :variables go-use-gometalinter t
                    go-tab-width 2
     )
   )

and here are some helpful commands that I found useful:

# run your tests
SPC m t s

TDD

https://golang.org/pkg/testing/

Books

I found a nice github repo which list many free books and paid books of the Go language.

Aaron Addleman
Aaron Addleman
Principal Automation Engineer

Fun with programming and infrastructure