Documentation
¶
Overview ¶
Package buildstamp reads the Go build information embedded in a binary of any format — js/wasm and wasip1/wasm included — and judges whether it was built from a clean commit.
debug/buildinfo reads ELF, Mach-O, PE, XCOFF and Plan 9 files only; given a WebAssembly module it answers "unrecognized file format", and so does `go version -m`. The go command writes the module information into every binary as text between two 16-byte sentinels (infoStart and infoEnd in cmd/go/internal/modload/build.go), in the format runtime/debug.ParseBuildInfo reads. This package finds the text between the sentinels and hands it to the standard parser, which works the same whatever the container format.
The question it exists to answer: a release built in CI after something wrote into the checkout (an output directory, a generated file) is stamped vcs.modified=true and its main module version gets a "+dirty" suffix — it is not the commit it claims to be. Clean reports that.
Index ¶
Constants ¶
const MaxFile = 1 << 30
MaxFile bounds what ReadFile reads.
const MaxInfo = 1 << 20
MaxInfo bounds the module information: a binary is untrusted input, and a start sentinel with no end nearby must not make the parser read megabytes.
Variables ¶
var ErrNoInfo = errors.New("no Go module information in the file")
ErrNoInfo is returned for a file that carries no Go module information (not a Go binary, or one built without module support).
Functions ¶
func Clean ¶
Clean reports an error unless bi was stamped from a version-controlled tree with no modification — vcs.revision present and vcs.modified=false — at revision want when want is not empty.
func Read ¶
Read returns the build information embedded in bin. The Go version is not part of the module information and is left empty.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
buildstamp
command
Command buildstamp reads the Go build information of binaries — wasm included, which `go version -m` cannot — and fails one built from a modified tree.
|
Command buildstamp reads the Go build information of binaries — wasm included, which `go version -m` cannot — and fails one built from a modified tree. |