Cross compilation of Go programs

If cgo is not required, crosscompile a static Go binary for a different platform like so:

CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -v .

If you need, e.g., sqlite support, then you need a crosscompiler. There is a guy who precompiles musl-based toolchains that can be found under

In practice, cross-compilation of a static binary with optional sqlite support looks like this:

CC=/path/to/armv7l-linux-musleabihf-cross/bin/armv7l-linux-musleabihf-gcc \
GOOS=linux \
GOARCH=arm \
go build -tags sqlite -ldflags "-linkmode external -extldflags -static" .

Pages linking here