Go交叉编译

Linux

1
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go

Windows

1
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go

macOS

1
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go

其他选项

$GOOS$GOARCH
androidarm
darwin386
darwinamd64
darwinarm
darwinarm64
dragonflyamd64
freebsd386
freebsdamd64
freebsdarm
linux386
linuxamd64
linuxarm
linuxarm64
linuxppc64
linuxppc64le
linuxmips
linuxmipsle
linuxmips64
linuxmips64le
linuxs390x
netbsd386
netbsdamd64
netbsdarm
openbsd386
openbsdamd64
openbsdarm
plan9386
plan9amd64
solarisamd64
windows386
windowsamd64