Modules a Go build requires that never reach the binary

Go command whose go.mod requires four modules and whose binary contains two

Test case
go-unlinked
Ecosystems
golang
Scanned at
source, artefact, image

The application and how it is built

A small Go command. Its go.mod requires four modules. The main package imports two of them, google/uuid and golang.org/x/text. A third, yaml.v3, is imported only by the tests. The fourth, jwt-go, is imported only by a file that is compiled when the build is given the debug tag, which the release build is not. The result is one static binary, shipped alone in an image built from scratch.

What gets hidden, and how

This case runs the other way from the rest: nothing is hidden from the dependency list, and the list says too much. go.mod must require every module any file in the module imports, under any build tag and in any test. The linker then includes only the packages the release build reaches. The Go toolchain also compiles its standard library into the binary, at its own version, and no dependency file mentions that.

ComponentMechanismIn the artefact?What happens to it
stdlib@1.27.4toolchainshipsthe Go standard library, compiled into every Go binary at the version of the toolchain that built it (GO_VERSION in tools/versions.env; update this line when that changes)
gopkg.in/yaml.v3@v3.0.0test-onlydoes not shipimported only by main_test.go; go.mod has to require it, the binary never contains it
github.com/dgrijalva/jwt-go@v3.2.0+incompatiblebuild-tagdoes not shipimported only by debug.go, which is compiled only with -tags debug; the release build leaves it out
golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6egraph-onlydoes not shiprequired by golang.org/x/text's own go.mod; no package of it is imported, so it is in the module graph and nowhere else

What a true SBOM would say

4 components ship, 1 of them transformed on the way in. 4 are known not to ship (1 build-tag, 2 graph-only, 1 test). Those influence the build or run during it; a tool may list them, as long as it marks them.

The list was written by hand from the build files, the lockfiles and the listing of the built archive, and the project's own proof-check.sh asserts what ends up in the artefact. It is in expected.json, and the full list of what ships is at the foot of this page.

What the tools reported

Shipped components found, by stage

Out of 4 that ship. Only the tools that scan all three stages are drawn; the table below has every tool.

024sourceartefactimagesyft, source: 3 of 4syft, artefact: 4 of 4syft, image: 4 of 4trivy, source: 3 of 4trivy, artefact: 4 of 4trivy, image: 4 of 4syft: 4 of 4trivy: 4 of 4
syfttrivy

Component by component

Ships: Y exact version, v wrong version, p wrong group or namespace, n not named. Does not ship: L listed and marked, X listed unmarked, · not listed. A tool appears under a stage only if it was run there, so an empty column never stands for a miss. Select a cell to see what is behind it.

Select a cell.

sourceartefactimage
Componentbomcdxgencyclonedx-gomod (whole module graph)cyclonedx-gomodsbom-toolsyfttrivybomcyclonedx-gomodsyfttrivycdxgendocker-scoutsyfttrivy
Ships. In the artefact, including components that were shaded or bundled on the way in.
example.com/trace/go-unlinked@*
github.com/google/uuid@v1.6.0
golang.org/x/text@v0.3.7
stdlib@1.27.4 toolchain
Present in the build, absent from the artefact. Plugins and their payloads, imported BOMs, and dependencies the build file requires but the artefact never contains. Listing one is right when it is marked as not shipping.
gopkg.in/yaml.v3@v3.0.0 test-only
github.com/dgrijalva/jwt-go@v3.2.0+incompatible build-tag
golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e graph-only

Every document

Content accuracyBaseline conformance
ToolFormatCompsIn scopeShipped foundWrong verWrong purlLeakedLabelledHashes okNTIA 2021NTIA/CISA 2026BSI v2.1
source
bom 0.8.0spdx663/410200/08.55.64.6
cdxgen 11.3.2cyclonedx333/400000/08.67.04.1
cyclonedx-gomod-mod 1.12.0cyclonedx443/400100/08.86.84.4
cyclonedx-gomod 1.12.0cyclonedx333/400000/08.96.74.5
sbom-tool 4.1.13spdx442/400200/010.05.13.7
syft 1.51.0cyclonedx663/400300/06.94.93.8
trivy 0.74.0cyclonedx873/400300/06.94.03.5
artefact
bom 0.8.0spdx444/400000/08.55.04.2
cyclonedx-gomod 1.12.0cyclonedx333/400000/08.66.34.4
syft 1.51.0cyclonedx444/400000/06.64.73.8
trivy 0.74.0cyclonedx654/400000/06.43.93.5
image
cdxgen 11.3.2cyclonedx222/400000/08.96.04.4
docker-scout 1.24.0spdx544/400000/09.85.83.7
syft 1.51.0cyclonedx444/400000/06.64.73.8
trivy 0.74.0cyclonedx544/400000/07.24.13.5

Details

Reading the result

A tool that reads go.mod reports what the module requires, and a tool that reads the binary reports what was linked; both are answering correctly, to different questions. The difference matters most for security. The unlinked modules here are old versions with published advisories, so an SBOM built from go.mod raises alarms about code that is not in the product, while one built from the binary does not. The standard library is the opposite risk: it is in every Go binary, and a source-stage SBOM usually cannot name the version that will be compiled in.

This is our interpretation. The counts above are what the run recorded; why a tool found or missed something is inferred from how the tool works, not established by the data. Limits of the benchmark.

Evidence

Ground truth: what ships

ComponentNote
pkg:golang/example.com/trace/go-unlinked@*primary component; a development build has no version of its own, so any version is accepted
pkg:golang/github.com/google/uuid@v1.6.0imported by main.go; linked
pkg:golang/golang.org/x/text@v0.3.7imported by main.go; linked. An old version with known advisories, chosen so that the security view has something real to find
pkg:golang/stdlib@1.27.4the Go standard library, compiled into every Go binary at the version of the toolchain that built it (GO_VERSION in tools/versions.env; update this line when that changes)