go build generates a binary for the platform you run it in. So, if I build antibody in a Linux machine - which uses Mach-O, it will not work in OS X - which uses ELF.
I wanted to distribute antibody at least for Linux and OS X, so I went out searching for how to do this in a not so complicated way…
I found an article from 2012, demonstrating how to compile Go itself for multiple platforms, so you can use the specific go to build the binary for the specific platform, which is a lot of work to do.
Then, I discovered gox, which compiles Go for multiple platforms and let you easily compile your application for them. It supports these platforms:
And it’s damn easy to use:
$ go get github.com/mitchellh/gox $ gox -build-toolchain $ gox
This will install
gox, build it’s toolchain (all the Go versions) and build your application for them. No further work required!
You can take a look at the source if you wish.
Hope this helps somebody!