version

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package version exposes build-time metadata injected via -ldflags.

The variables Version, Commit, and BuiltAt are normally set by the Makefile (or CI) using linker flags. When they are not injected — most notably for `go install ...@vX.Y.Z` binaries, which cannot run ldflags — Current() falls back to the Go toolchain's own build information (debug.ReadBuildInfo): the module version, the VCS revision, and the VCS commit time. That fallback is still honest: it only ever reports metadata the toolchain itself recorded, and it keeps the plain "dev"/"unknown" values when the binary carries no such evidence (a plain `go build`/`go run` inside a module reports "(devel)", which stays "dev"). GSEER never claims a version it cannot substantiate (SPEC-03 §4: checksums, not signatures, in v0.0.1; `gseer doctor` prints the running binary's SHA-256).

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the semantic version string, e.g. "v0.0.1".  When built
	// without ldflags it is "dev" — Current() then tries the module
	// version recorded by the toolchain (set for `go install ...@vX.Y.Z`)
	// and reports "dev" only when that yields nothing.
	Version = "dev"
	// Commit is the VCS commit hash the binary was built from.  Empty
	// when built without ldflags; Current() falls back to the toolchain's
	// vcs.revision stamp (full hash — unambiguous next to a release page)
	// and otherwise reports "unknown".
	Commit = ""
	// BuiltAt is the build timestamp in RFC3339 form.  Empty when built
	// without ldflags; Current() falls back to the toolchain's vcs.time
	// stamp (also RFC3339) and otherwise reports "unknown".
	BuiltAt = ""
)

Variables injected via -ldflags "-X ...". Defaults are intentionally honest: when not injected, we say so plainly rather than fabricating a version (AC-8.x documentation honesty; the honesty floor).

Functions

This section is empty.

Types

type Info

type Info struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	BuiltAt   string `json:"built_at"`
	GoVersion string `json:"go_version"`
}

Info is the structured form of the build metadata. The CLI's `version` command renders this; future surfaces (doctor, /api/v1/version) reuse it.

func Current

func Current() Info

Current returns the build metadata for the running binary. Go runtime version is always available; the other fields reflect ldflags injection with the toolchain's build information as the honest fallback (see the package comment).

func (Info) String

func (i Info) String() string

String renders the version block as a human-readable multi-line string. Format is stable so that tests and the QUICKSTART can pin it.

Jump to

Keyboard shortcuts

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