Cross Compiling with gb
gb supports compiling go source code for operating systems and architectures other than the one you are developing on.
Usually, you’d simply run:
$ gb build
To compile for another target OS/architcture you could run:
$ env GOOS=linux GOARCH=amd64 gb build
In this example, we’re targeting AMD64 (x86-64) linux, like CentOS.
Note that by default, the binary output by the above command will be bin/{app}-linux-amd64.
Valid combinations of GOOS and GOARCH:
$GOOS $GOARCH android arm darwin 386 darwin amd64 darwin arm darwin arm64 dragonfly amd64 freebsd 386 freebsd amd64 freebsd arm linux 386 linux amd64 linux arm linux arm64 linux ppc64 linux ppc64le linux mips linux mipsle linux mips64 linux mips64le netbsd 386 netbsd amd64 netbsd arm openbsd 386 openbsd amd64 openbsd arm plan9 386 plan9 amd64 solaris amd64 windows 386 windows amd64