I have a small Go service that runs on a Raspberry Pi tucked behind the TV. Compiling it on the Pi itself works, but it's slow and the SD card hates me for it. So I finally did the thing everyone says Go is good at and built it on my laptop instead.
It really is just two variables:
GOOS=linux GOARCH=arm GOARM=7 go build -o pi-service ./cmd/pi-service
GOARM=7 matters. The Pi 3 is ARMv7-capable, and without it you get a slower ARMv6 build. If you're targeting a Pi Zero or the original Pi, you want GOARM=6. For the 64-bit OS on a Pi 3/4 it'd be GOARCH=arm64 and no GOARM at all. The whole thing only works this cleanly because my service is pure Go with no cgo. The moment you link against C, you need a cross-toolchain and the magic evaporates.
scp the binary across, restart the unit, done. A build that took the better part of a minute on the Pi now finishes before I've looked up from the keyboard. I'd been avoiding this for no reason at all.