Languages

SBOMs for Go

Go has no built-in SBOM command. sbombox generate uses cyclonedx-gomod if installed, then cdxgen or syft. For a release, describe the binary you ship: that lists only what was compiled in.

At a glance

Go and SBOMBox
Package managerBuilt-in SBOM commandWhat sbombox generate runsLockfile to commit
Go modulesNo (go version -m prints build info)cyclonedx-gomod, then cdxgen or syftgo.sum

Generate with SBOMBox

curl -fsSL https://sbombox.com/install.sh | sh

sbombox generate -o sbom.json
sbombox score sbom.json

Run it from the directory that holds go.mod and go.sum. The default installer adds syft. Install cyclonedx-gomod to use the native tool:

go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest

To pin the choice, set SBOMBOX_GENERATOR to one or more generator names, comma-separated. SBOMBox tries them in that order and skips any that are not installed. An unknown name fails with the list of valid names.

SBOMBOX_GENERATOR=syft sbombox generate -o sbom.json

Valid names for Go: cyclonedx-gomod (alias golang), cdxgen, syft.

Use cyclonedx-gomod or syft

cyclonedx-gomod has three modes: mod describes the whole module, app describes one main package as built, and bin reads a compiled binary. For a release SBOM, use app:

cyclonedx-gomod app -json -licenses -output sbom.json -main cmd/api .

To describe the module instead:

cyclonedx-gomod mod -json -licenses -output sbom.json .

Go 1.25 and later can print the build information embedded in a binary as JSON. It is not an SBOM, but it shows exactly which modules were linked:

go version -m -json ./bin/api

syft reads the same build information from a compiled binary:

syft ./bin/api -o cyclonedx-json=sbom.json
# See what lowers the score
sbombox score sbom.json --format detailed

# Check a ruleset, e.g. EU Cyber Resilience Act readiness
sbombox compliance sbom.json -p cra-readiness

# Upload it to the active project, labelled with the release
sbombox push sbom.json --version v1.4.0

Monorepos and workspaces

Known gaps and how SBOMBox handles them

Troubleshooting

Common Go issues
SymptomCauseFix
No lockfile for golang: transitive dependencies may be missing and versions may be guessed.go.sum not committedRun go mod tidy, commit go.sum
Components with no licenseLicenses not detectedUse cyclonedx-gomod with -licenses
Test-only modules in the SBOMModule-level SBOMUse cyclonedx-gomod app or scan the binary
go version -m -json failsGo older than 1.25Upgrade Go, or use go version -m without -json

In CI, run the same commands. See GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, Bitbucket Pipelines or CircleCI, or use the GitHub Action.