Go
Build Commands
Compile Go programs into fast, statically-linked binaries. Learn build flags, cross-compilation, build tags, and optimization techniques for production deployments.
12 commands
Pro Tips
Cross-compile with 'GOOS=linux GOARCH=amd64 go build -o app' — no extra toolchain needed.
Use 'go build -ldflags="-s -w"' to strip debug info and reduce binary size by ~30%.
Use build tags with '//go:build integration' to separate unit and integration tests.
Common Mistakes
CGO_ENABLED=1 (default) links to C libraries, making binaries less portable. Set CGO_ENABLED=0 for truly static binaries.
Stripping with '-ldflags="-s -w"' removes debug info. Don't use in development — you'll need stack traces.