Golang Cross Platform Build (GOOS and GOARCH)

Are you developing a software using golang on a macOS or other operating system (OS) and wanted
to compile for other OS? You can compile a golang binary for other platforms using GOOS and GOARCH.

Here is an example in compiling a golang binary for Linux on a macOS terminal:

GOOS=linux GOARCH=amd64 go build


GOOS (Operating System) GOARCH (Architecture e.g. amd64)
aix ppc64
android 386
amd64
arm
arm64
darwin 386
amd64
arm
arm64
dragonfly amd64
freebsd 386
amd64
arm
illumos amd64
js wasm
linux 386
amd64
arm
arm64
mips
mips64
mips64le
mipsle
ppc64
ppc64le
s390x
nacl 386
amd64p32
arm
netbsd 386
amd64
arm
arm64
openbsd 386
amd64
arm
arm64
plan9 386
amd64
arm
solaris amd64
windows 386
amd64
arm