Packages, modules and tooling · 3 MIN READ
Reproduce the artifact: vendor, build tags and embedded files
Check the source and assets that a clean build actually receives.
A successful build in your checkout can depend on uncommitted generated files, platform-specific source or an asset missing from the release archive. Reproducibility concerns the whole input set: toolchain, selected modules, build constraints, generated files and embedded data.
Packages and production tooling · A MAP OF THE IDEA
- Source checkout
- Selected files
- Dependencies and assets
- Release binary
Useful when
- Check the source and assets that a clean build actually receives.
Watch out
- Compilation does not automatically invoke go generate. Generation is an explicit workflow step whose tool version and output need their own checks.
Implementation & operation cost: Vendor and generated assets increase repository and review volume; the payoff is explicit repeatable release inputs.
Inspect the selected files and dependencies
go list exposes which source and embedded files belong to the selected target. Build tags and GOOS/GOARCH can select different implementations. An import that works on your Mac may require cgo or assembly on another target; do not infer portability from a package download.
go list -f '{{.GoFiles}} {{.IgnoredGoFiles}} {{.EmbedFiles}}' ./...
go list -deps ./...
go env GOOS GOARCH CGO_ENABLEDThe file selection is concrete evidence for the current build configuration. Repeat it for the intended target and inspect dependency code before promising portability to a restricted runtime.
Treat vendor as a derived dependency tree
Regenerate vendor after reviewing a dependency change and check it with the corresponding go.mod. Vendor mode deliberately uses that tree instead of treating a full module cache as the source of truth. Toolchain and platform differences still matter.
go mod vendor
go test -mod=vendor ./...
go build -mod=vendor ./...Run these in a development checkout or clean CI worktree. If module declarations and vendor metadata disagree, regenerate from the reviewed graph rather than hand-editing copied dependency source.
Generated and embedded inputs are release inputs
go generate is explicit; go build does not run arbitrary generators for you. Check generated files or run a pinned generator in a defined build step. GopherForge currently does not preserve arbitrary non-Go embed assets while vendoring; learning native build commands here does not change that app limitation.
TAKE THIS WITH YOU
Build the clean release input set, not just the current working tree. Verify tags, generated files and assets, and keep vendor consistent with the reviewed graph.
Check your understanding
When does go build automatically run go generate?
Go to the source
Progress stays in this browser. No account needed.