How to Cross-Compile Go Programs for Windows, macOS, and Linux
Go programs can be easily cross-compiled for various operating systems like
Windows, macOS, and Linux using GOARCH
and GOOS
environment variables, which
denote the architecture and target OS respectively.
By default, they’re set to your system’s architecture (GOHOSTARCH
) and OS
(GOHOSTOS
):