Documentation
¶
Overview ¶
Package buildinfo holds build-time identifiers populated at link time. Keeping these in a leaf package lets both the CLI command layer and the runtime primitives reference them without creating an import cycle.
The public surface is intentionally minimal: a BuildInfo interface, a constructor, and a process-wide accessor. The implementation is a private struct that is constructed exactly once, at program start, from cmd/root.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(major, minor, patch, commitSHA, shortCommitSHA, date, platform string)
Init publishes the process-wide BuildInfo. It is intended to be called once from cmd/root.go's init(), after the -ldflags-populated string variables in the cmd package have been observed. Subsequent calls are no-ops.
Types ¶
type BuildInfo ¶
type BuildInfo interface {
GetMajorVersion() string
GetMinorVersion() string
GetPatchVersion() string
GetCommitSHA() string
GetShortCommitSHA() string
GetDate() string
GetPlatform() string
GetSemVersion() string
}
BuildInfo provides read-only access to build-time identifiers.
func Get ¶
func Get() BuildInfo
Get returns the process-wide BuildInfo. Before Init is called it returns an instance with empty strings.
func NewBuildInfo ¶
NewBuildInfo constructs an immutable BuildInfo from the given identifiers. SemVersion is derived from the major/minor/patch trio.