GOOS and GOARCH

The two Go settings that choose the target operating system and processor family a build produces a binary for.

In more detail

Examples are GOOS=linux, darwin or windows and GOARCH=amd64 or arm64. Setting them before go build is all cross compilation takes for pure Go code. Inside a running program, runtime.GOOS and runtime.GOARCH report the pair the binary was built for.

Example

GOOS=linux GOARCH=arm64 go build -o probe .

Related terms

Taught in

References