Documentation
¶
Overview ¶
Package buildinfo resolves and formats canonical build identity metadata for WindShare Go binaries, matching the release and commit contract used by wsrelay.
Index ¶
Constants ¶
const ( // LinkerPackage is the Go import path that owns the -ldflags -X stamp symbols. LinkerPackage = "github.com/windshare/windshare/internal/buildinfo" // CommitHexLength is the exact length of a canonical lowercase Git SHA-1. CommitHexLength = 40 // MaxReleaseLength bounds canonical semantic release tags (vX.Y.Z). MaxReleaseLength = 64 // UnstampedLabel is displayed when a binary has neither linker-stamped nor // embedded Git VCS identity. UnstampedLabel = "unstamped" )
Variables ¶
var ( // ErrInvalidCommit reports a missing or malformed 40-character lowercase hex SHA. ErrInvalidCommit = errors.New("build commit must be a 40-character lowercase hex SHA") // ErrInvalidRelease reports a non-canonical release tag. ErrInvalidRelease = errors.New("build release must have the form vX.Y.Z without leading zeroes") // ErrDirtyRelease reports an attempt to stamp a release build as dirty. ErrDirtyRelease = errors.New("release build cannot be marked dirty") // ErrInvalidDirty reports an unrecognized dirty flag spelling. ErrInvalidDirty = errors.New("build dirty flag must be true, false, 1, or 0") )
Functions ¶
func IsValidCommit ¶
IsValidCommit reports whether value is a 40-character lowercase hex SHA.
func IsValidRelease ¶
IsValidRelease reports whether value is a canonical vX.Y.Z release tag without leading zeroes, prerelease/build suffixes, or uint64 overflow.
Types ¶
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info represents a validated binary build identity.
Release builds always carry both a canonical vX.Y.Z tag and a 40-character lowercase Git SHA and are never dirty. Revision builds carry a commit SHA and a dirty bit. Unstamped builds carry neither.
func Current ¶
func Current() Info
Current resolves the running binary's build identity, preferring explicit linker stamps over Go's embedded VCS metadata.
func FromBuildInfo ¶
FromBuildInfo extracts a Git revision identity from Go's embedded BuildInfo.
func ParseExplicit ¶
ParseExplicit validates raw linker-stamped build strings.
func Resolve ¶
Resolve computes the validated build identity from explicit linker values and Go's runtime/debug.BuildInfo.
When any explicit value is present, it takes full authority without falling back to ambient VCS metadata so a malformed explicit stamp never silently reports a different revision.
func (Info) FormatLine ¶
FormatLine formats the CLI version line ("<program> <identity>").
func (Info) LDFlags ¶
LDFlags formats the go build -ldflags -X argument that stamps this validated build identity into a binary, or "" for an unstamped Info.