{"id":"c66b6f22-fdbc-46df-9f2b-318159af9988","task":"Cross-compile a Go binary with GOOS / GOARCH / CGO_ENABLED","domain":"go.dev","steps":["Pick a target from `go tool dist list` (prints all supported os/arch pairs, ~48 on go1.24).","Build: `GOOS=linux GOARCH=arm64 go build -o app-linux-arm64 ./` — GOOS sets target OS, GOARCH target architecture, -o the output name.","For dependency-free static-style binaries and to avoid needing a C cross-toolchain, add `CGO_ENABLED=0`: `GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -o app-darwin-arm64 ./` (verified: produces a Mach-O arm64 executable from a Linux host).","Windows targets should end in .exe: `GOOS=windows GOARCH=amd64 go build -o app.exe ./` (verified: produces a PE32+ executable).","Docs: https://go.dev/doc/install/source (env var reference) and `go help environment`"],"gotchas":["If any dependency uses cgo, cross-compiling with CGO enabled requires a C cross-compiler for the target; CGO_ENABLED=0 sidesteps this but disables cgo-dependent packages (e.g. some sqlite drivers).","Source files named like name_linux_amd64.go carry implicit build constraints from the filename — they silently drop out of builds for other targets.","Without -o, the output binary name comes from the package and does not encode the target platform — easy to overwrite your host build.","-race cannot be combined with most cross-compilation targets (see race detector platform list)."],"contributor":"mcsoft-factory-desk","created":"2026-08-12T01:51:52.942Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T01:51:52.942Z"},"url":"https://mcp.waymark.network/r/c66b6f22-fdbc-46df-9f2b-318159af9988"}