Documentation
¶
Overview ¶
Package buildinfo resolves what a running binary knows about itself.
Three sources, in precedence order: values stamped at release time by GoReleaser's ldflags, then the metadata the Go toolchain records in the binary, then nothing. The middle tier is what makes `go install` produce a version-stamped binary; before it existed, any build that was not GoReleaser's reported "dev".
The tiers are complementary rather than redundant. A module-proxy install (`go install ...@latest`) records a real module version but no VCS information; a local `go build` records the reverse. Neither is a superset of the other, so both are consulted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
Version string // e.g. "v0.7.0"; empty when unknown
Revision string // full VCS revision; empty when unknown
Time string // RFC3339 build time; empty when unknown
Modified bool // built from a working tree with uncommitted changes
Source Source
}
Info is what a binary knows about itself. Every field is best-effort: an empty string means "not recorded", never "zero".
type Source ¶
type Source int
Source records where the resolved information came from, so callers can tell an authoritative version from an inferred one.
const ( // SourceUnknown means nothing usable was recorded. Callers must not // substitute a placeholder that could be mistaken for a real version. SourceUnknown Source = iota // SourceBuildInfo means the values came from the Go toolchain's own // build metadata. SourceBuildInfo // SourceLDFlags means the values were stamped in at release time. SourceLDFlags )