Documentation
¶
Overview ¶
Package version centralizes build-identity reporting for cmd/switchboard, ported from core-agent's / k8s-lookout's internal/version. The package vars are overridable at release time via -ldflags. Without them there are two fallbacks, and which one applies depends on how the binary was built:
- Built from a checkout (`go build`, `go run`): Go embeds vcs.* settings when -buildvcs=true, so the SHA and dirty flag are real and the version stays the -dev default — the marker that says "this is nobody's release".
- Built from the module cache (`go install module@version`): there is no checkout to stamp, so vcs.* is absent and the module version is the only identity there is. Read since #43; before that an `@v0.1.0` install reported "v0.1.0-dev (commit none, built unknown)", byte-identical to someone's uncommitted tree.
Since Go 1.24 a checkout build stamps Main.Version as well, as a pseudo-version derived from the tags, so the two cases are told apart by the vcs.* stamp rather than by the module version — see resolve.
Known limit, shared with core-agent: a build from a LINKED git worktree reads the main checkout's git state, so the SHA and dirty flag describe that tree rather than the worktree being built.
Release process:
go build -ldflags "\ -X github.com/go-steer/switchboard/internal/version.Version=v0.1.0 \ -X github.com/go-steer/switchboard/internal/version.Commit=$(git rev-parse HEAD) \ -X github.com/go-steer/switchboard/internal/version.Date=$(date -u +%Y-%m-%dT%H:%M:%SZ) \ " ./cmd/switchboard
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Version is the semver tag for released builds, or vX.Y.Z-dev // for in-development builds. Bump this manually on main right // after cutting a release. Version = "v0.11.0-dev" // Commit is the git SHA the binary was built from. Defaults to // "none" so the debug.BuildInfo fallback can detect that nothing // was injected; release builds get the full SHA via -ldflags. Commit = "none" // Date is the build timestamp in ISO 8601. Same default-sentinel // pattern as Commit. Date = "unknown" )
Build-time metadata. Defaults assume an in-development build off main; release-time -ldflags injection overrides them with the real tag, commit, and build date.
Functions ¶
Types ¶
This section is empty.