Releasing Versioned Go Apps From Travis

So, thanks to Redditor vruin, I learned that there’s an easier way to add a version number than what I was doing:

The way described in the blog post uses the -ldflags go build parameter instead of my relatively convoluted approach of using go generate to create a version.go file. I just needed to make a couple of changes to the version scheme to make it work for me:

GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=`git describe --tags --long`" -o release/terminator

The next thing I needed to do was to package up those builds and push them back out to Github. I followed some excellent instructions, just making a few changes to take out the need for a make file:

I’ve put this into practice on my “Terminator” application at [0] and I’m now confident I can deploy new distributions of my applications automatically.