Makefile + GoLang FTW

Apr 28 2013

I like Go (Golang) because it keeps me busy and rarely annoyed. One thing that was annoying me was the lack of a build in dependency managment system. This honsetly scared me when I first started to learn Go. I would never know when I ran go get ... if i was getting the version of the dependency that I was supposed to get!

My solution: Keep everything in source control. This means that each project i work in has its own GOPATH and I commit all of src/ to my repo. This might seem a bit bulky, but I'll never have to worry about accidental version or api changes in my projects.

Example Makefile

default: run

package = {your_package}

.PHONY: default run

                 CGO_ENABLED=0 GOPATH=`pwd` go run -race $(package).go

                 CGO_ENABLED=0 GOPATH=`pwd` go test -i src/$(package)/*.go  
                 CGO_ENABLED=0 GOPATH=`pwd` go test src/$(package)/*.go

                 GOPATH=`pwd` go build -v $(package).go

                 go fmt src/$(package)/*.go