Cross compile golang

Jan 6, 2016 22:09 · 79 words · 1 minute read Development golang

Since version 1.5 it has been easier to generate Go binary for another System.

Just use go build (dont use go install) with GOOS, GOARCH, and GOARM (for ARM based system)

for example generate main.go binary for freebsd/amd64:

GOOS=freebsd GOARCH=amd64 go build main.go

and for generate android binary:

GOOS=android GOARCH=arm GOARM=7 go build .

for list of supported GOOS and GOARCH please visit the official golang environment documentation

*this article is referenced from @rakyll post about Go Cross Compilation