Documentation
¶
Overview ¶
Package buildinfo provides build metadata for Spirit binaries.
It supports two sources of build information:
- Compile-time injection via -ldflags (preferred for release binaries)
- runtime/debug.ReadBuildInfo() VCS settings (automatic for dev builds from a git checkout)
The Set() function should be called from main() with the ldflags-injected variables. Get() returns the resolved build info, preferring ldflags values when available and falling back to debug.ReadBuildInfo().
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Set ¶
func Set(version, commit, date string)
Set stores the compile-time injected values from -ldflags. Call this once from main() before any call to Get().
Example ldflags:
go build -ldflags "-X main.version=v1.2.3 -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
Types ¶
type Info ¶
type Info struct {
Version string // version (e.g. "v1.2.3"), or "dev"
Commit string // full git commit hash, or "unknown"
Date string // build date in RFC3339, or "unknown"
Modified bool // true if the working tree had uncommitted changes
GoVer string // Go version used for the build
}
Info holds the resolved build metadata.
type VersionFlag ¶
type VersionFlag bool
VersionFlag is a Kong-compatible flag that prints detailed build info and exits.
func (VersionFlag) BeforeReset ¶
BeforeReset is called by Kong before argument parsing when --version is passed. It prints the full build info and exits with code 0.