version

package
v2.8.0-dev.7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package version centralizes build-identity reporting for both cmd/core-agent and cmd/core-agent-tui. The package vars are overridable at release time via -ldflags; plain `go build` falls back to the VCS metadata Go embeds when -buildvcs=true (the default since Go 1.18) so dev builds still report a real SHA. `go install module@version` builds carry no VCS metadata, so those fall back to the module version Go records instead: exact tags report the tag, and branch installs report the pseudo-version, whose suffix encodes the commit time and short SHA.

Release process (see docs/release-process.md):

go build -ldflags "\
  -X github.com/go-steer/core-agent/v2/internal/version.Version=v2.2.0 \
  -X github.com/go-steer/core-agent/v2/internal/version.Commit=$(git rev-parse HEAD) \
  -X github.com/go-steer/core-agent/v2/internal/version.Date=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
" ./cmd/core-agent ./cmd/core-agent-tui

After cutting a tag, bump Version below to the next minor + "-dev" (e.g. v2.1.0 release → main becomes v2.2.0-dev) so post-release dev builds report their next-target version.

Index

Constants

This section is empty.

Variables

View Source
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 so post-release builds report the
	// next target version. Enforced by
	// dev/ci/presubmits/verify-version-fallback so drift caught in
	// v2.4→v2.5→v2.6 (skipped bumps produced stale --version output
	// on go-installed binaries during the v2.7.0-dev.N demo drive)
	// can't happen again silently.
	Version = "v2.8.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

func Effective added in v2.8.0

func Effective() string

Effective returns just the version token String() reports (module version for `go install module@version` builds, the ldflags or in-repo value otherwise). For callers that advertise a version string (e.g. the A2A agent card) and want the same identity --version prints, without the commit/date suffix.

Cached: the value is immutable after link time, debug.ReadBuildInfo re-parses on every call (go1.26), and one caller serves the unauthenticated agent-card route per request.

func String

func String(prog string) string

String renders the build identity for a --version flag. prog is the binary name (e.g. "core-agent", "core-agent-tui") so the format starts with what the operator typed.

Format:

<prog> <semver> (commit <8-char-sha>[, modified], built <date>)

Fields still holding their "none"/"unknown" sentinels are omitted rather than printed; when neither commit nor date is known the parenthesized suffix is dropped entirely (the module version alone identifies the build for `go install module@tag` binaries).

The leading two tokens are always (prog, version) so scripts can grep without parsing the parenthesized suffix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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