Documentation
¶
Overview ¶
Package version exposes build metadata injected at link time via `go build -ldflags "-X ...Version=..." -ldflags "-X ...Commit=..." -ldflags "-X ...BuildTime=..."`. Default values keep development builds informative without requiring an LDFLAGS dance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BuildTime = ""
BuildTime is the ISO-8601 UTC timestamp at which the binary was built. Set at link time via -ldflags; on a bare `go build` of a git checkout falls back to vcs.time from runtime/debug.ReadBuildInfo (the HEAD commit timestamp, which is close enough for diagnostics). Empty when neither source is available.
var Commit = ""
Commit is the short git SHA the binary was built from. Set at link time via -ldflags; on a bare `go build` of a git checkout falls back to the 7-char prefix of runtime/debug.ReadBuildInfo's vcs.revision (with "-dirty" appended when the working tree had uncommitted changes at build time). Empty when neither source is available — e.g. a tarball build with no .git.
var Version = "dev"
Version is the human-readable build version. Set at link time by the Makefile + release workflow to the git tag (e.g. "v1.0.0") or `git describe` output for in-development builds. Defaults to "dev" for `go run` / `go test` / bare-`go build` invocations.
Functions ¶
func String ¶
func String() string
String returns a single-line summary suitable for logging or for the `gophertrunk version` subcommand: "vX.Y.Z (sha=ABC1234, built=2026-05-13T19:00:00Z)". Empty Commit / BuildTime are omitted so the most basic dev builds (no git, no -ldflags) still stay compact ("dev").
Issue #275 retest cycles repeatedly tripped on stale builds whose log lines read `build=dev` and gave no hint of which commit was actually loaded. To prevent that recurring without forcing users to remember `-ldflags`, on first call we populate empty Commit / BuildTime from Go's auto-injected VCS info — explicit `-ldflags` still wins (the populate runs only on empty fields).
Types ¶
This section is empty.