version

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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.
	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

func String

func String(prog string) string

String renders the build identity for `switchboard version`, the --version flag, and the startup log line. prog is the binary name so the format starts with what the operator typed.

Format:

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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