go tool dist listPrint supported GOOS/GOARCH pairs. Useful in Go CLI workflows.
Cross-compilation, build flags, ldflags, reproducible releases, CGO controls, and packaging patterns with the go command.
Cross Compilation commands and patterns for the Go command.
go tool dist listPrint supported GOOS/GOARCH pairs. Useful in Go CLI workflows.
GOOS=linux GOARCH=amd64 go build -o dist/app-linux-amd64 .Cross-compile for Linux amd64. Useful in Go CLI workflows.
GOOS=darwin GOARCH=arm64 go build -o dist/app-darwin-arm64 .Cross-compile for macOS Apple Silicon. Useful in Go CLI workflows.
GOOS=windows GOARCH=amd64 go build -o dist/app.exe .Cross-compile a Windows executable. Useful in Go CLI workflows.
CGO_ENABLED=0 go build .Build without CGO for simpler static-ish builds. Useful in Go CLI workflows.
Build Flags commands and patterns for the Go command.
go build -trimpath .Remove local filesystem paths from compiled output. Useful in Go CLI workflows.
go build -ldflags="-X main.version=1.2.3" .Set variables at link time with -ldflags -X. Useful in Go CLI workflows.
go build -tags "prod netgo" .Compile with specific build tags enabled. Useful in Go CLI workflows.
go build -mod=readonly ./...Disallow automatic go.mod/go.sum edits during build. Useful in Go CLI workflows.
go build -json ./...Use JSON output to integrate with tools. Useful in Go CLI workflows.
Release Packaging commands and patterns for the Go command.
go test ./... && go build -trimpath -o ./dist/app .A typical release pipeline pattern. Useful in Go CLI workflows.
go generate ./... && go build ./...Run go generate directives before compiling. Useful in Go CLI workflows.
go install ./cmd/...Install all command packages under cmd/. Useful in Go CLI workflows.
Inspection and Binary Introspection commands and patterns for the Go command.
go version -m ./dist/appShow module/build info embedded in a binary. Useful in Go CLI workflows.
go tool nm ./dist/appInspect symbols in a compiled binary. Useful in Go CLI workflows.
go tool objdump ./dist/appDisassemble functions from a compiled binary. Useful in Go CLI workflows.