version

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 4 Imported by: ? 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 works out which git-stack this binary is.

Three sources are tried in order: the value goreleaser stamps in with ldflags at release time, the module version recorded by `go install github.com/DomBlack/git-stack@vX.Y.Z`, and finally the VCS details that `go build` records for a checkout, so a dev build still says which commit it came from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string) int

Compare orders two versions: negative when a is older than b, zero when equal, positive when newer. Anything that is not vX.Y.Z (a dev build, a pseudo version) sorts before every real release.

func IsRelease added in v0.4.0

func IsRelease(v string) bool

IsRelease reports whether v is a release version (vX.Y.Z), not a dev build or pseudo version.

Types

type Info

type Info struct {
	// Version is "vX.Y.Z" for a release, a pseudo version for `go install
	// @main`, or "dev" for a local build.
	Version string `json:"version"`
	// Release is true when Version names a published release that
	// `git stack update` can compare against.
	Release bool `json:"release"`
	// Commit is the short VCS revision when known.
	Commit string `json:"commit,omitempty"`
	// Date is the commit date (YYYY-MM-DD) when known.
	Date string `json:"date,omitempty"`
	// Dirty is true when the checkout had uncommitted changes.
	Dirty bool `json:"dirty,omitempty"`

	GoVersion string `json:"go"`
	OS        string `json:"os"`
	Arch      string `json:"arch"`
}

Info describes the running binary.

func Current

func Current() Info

Current resolves the running binary's version.

func Resolve

func Resolve(ldflags string, bi *debug.BuildInfo) Info

Resolve builds an Info from the linker value and the build info. It is split out from Current so tests can feed in fixed inputs.

func (Info) String

func (i Info) String() string

String is the human form: "v1.2.3", or "dev (3a9f2c1, 2026-09-30, dirty)".

Jump to

Keyboard shortcuts

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