buildinfo

package
v0.164.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package buildinfo resolves the running WB binary's version so that any package can record it, not just the command layer.

Resolution goes through github.com/strongo/buildinfo.Get("wb"), the fleet-wide shared module every CLI in this fleet now reports its version through: a release build stamps its link-time -X variables (see .goreleaser.yml's ldflags, which target github.com/strongo/buildinfo directly), a `go install` of the module leaves the version in the embedded build info, and an ad-hoc `go build` has neither, falling back to this package's own Unknown. Resolving that order in one shared place keeps `wb version`, `wb --version`, and the provenance WB writes into worktrees from ever disagreeing about which binary is running.

Index

Constants

View Source
const Unknown = "unknown"

Unknown is reported when no version can be resolved at all. It is wb's own placeholder for strongobuildinfo's terminal fallback ("dev"), which this package translates on the way in, so wb's public contract here (and the self-update undetermined-version list in cmd/wb/selfupdate.go) never changes shape.

Variables

This section is empty.

Functions

func Date added in v0.67.26

func Date() string

Date returns the resolved build's date (RFC 3339), or "" when unknown.

func JSON added in v0.136.0

JSON returns the resolved build identity as the fleet-wide `version --json` contract type (github.com/strongo/buildinfo.VersionJSON), the one exported shape a probing host's cliinstall status prober decodes (cli-install#req:version-json-contract in strongo/cli-helpers: "The writer and the reader MUST share one exported Go type"). It performs no I/O (cli-install#req:version-json-side-effect-free): resolved is computed once at package init, and Version() folds in any test-only Set override the same way the "wb version" text banner already does, so the two surfaces can never disagree about which version this binary is — except for the undetermined placeholder spelling itself, which JSON() alone translates to the contract's "dev" (see jsonUndeterminedVersion); the text banner keeps printing Unknown ("unknown") unchanged.

func Modified added in v0.67.26

func Modified() bool

Modified reports whether the resolved build tree had uncommitted changes, per strongobuildinfo's "+dirty" commit-suffix convention.

func Revision added in v0.67.26

func Revision() string

Revision returns the resolved build's commit SHA with any "+dirty" suffix stripped, or "" when genuinely unknown. Pair with Modified for the decoration the bare SHA no longer carries.

func Set

func Set(v string)

Set overrides the resolved version. The command layer no longer needs to call this at start-up — .goreleaser.yml's ldflags target github.com/strongo/buildinfo directly, so a release build's version is already resolved by the time this package initializes. Set remains so tests can force a deterministic value (e.g. asserting that WB provenance appends a new entry when the reported version changes) without relinking the binary.

func Version

func Version() string

Version returns the override set via Set, if any, else the version resolved from github.com/strongo/buildinfo.Get("wb"). It never returns an empty string, so callers can record it unconditionally.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL