CICD-073 · Build a static Go Linux target
Encyclopedia · Language build toolchains · All snippets
Previous · CICD-072 · Next · CICD-074
1. Where it fits
- Placement Bash run step following checkout, or equivalent lab terminal.
- Prerequisites source repository with committed build manifest and pinned matching toolchain.
- Platforms local-linux, github-actions, gitea-actions.
2. Copy the snippet
bash
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -o dist/app ./cmd/app
file dist/app3. How it works
GOOS and GOARCH target Linux AMD64, and disabling CGO removes native C integration. The second command inspects the generated executable format.
4. Verify the result
Include matching modules and test the resulting binary on Linux AMD64.
Validation syntax-validated (Bash parse). Status definitions.