I was on the quest of searching the Holy Grail of Go programming, and I found something, which I doubt that it is, but close enough – for the first sight.
I have several problems with GO, first, that I write my code on an OSX box, and I’ll run the programs on Linux hosts, so I have to solve the cross compilation; my second problem with Go, that I don’t really like the “There is a GO project folder, and all the GO projects are relying under” approach. It makes githubbing painful.
The first problem of mine is easily achievable since GO 1.5: we only need a GOOS environment variable and we can compile to different OS-es (see more at Dave Cheney: http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5) easily.
The second problem is easily solvable too, just we have to start using the GOPATH variable for every GO project we have.
I don’t really wanted to use any external dependencies, so I decided to use ‘Makefile’ – it was proven good for decades. (I don’t know if this applies on bigger projects, but the ones I wrote it is fairly good.)
Let’s check out the makefile of the binlogstreamer!
If you type ‘make’ in the checked out project folder, it will download all the dependencies and build the application there. You can run that locally, test it, etc. If you change the code, then you can compile it again, etc.
On my OSX host, I can build for our linux boxes as well I just type ‘make linux’ and I’ll have the binary which I can run on our servers. I can put the binary to the puppet repository, and git push it.
After I made my changes in the code, and I’d like to push to git, then I just run ‘make clean’ which removes all the binaries, and all dependencies, and leaves just the code there. I can commit and push it when I want.
So far this approach worked to me. Do you have any better?