Help us shape the future of Go! Take the 2026 Go Developer Survey

version

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package version answers what build of rig this is.

Three kinds of binary have to answer it, and only one of them is built by the release:

  • `go install github.com/simonjanss/rig/cmd/rig@v0.3.0` stamps nothing, but the module version is in the build info, and it is exact.
  • A release archive is built with -ldflags, because goreleaser knows the tag before the compiler does.
  • `make build` from a checkout has neither, and what is useful there is the commit — which the toolchain records on its own, except in a git worktree, where it records nothing. So the commit is reported when it is there and the version stands alone when it is not, rather than being relied on.

So the answer is assembled from whatever of those is present, in that order of trust, and never guessed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String() string

String is the version of the running binary.

Types

type Info

type Info struct {
	// Version is a semantic version for a released build, "(devel)" for one
	// built from a checkout, and "unknown" when there is no build info at all —
	// which happens under `go test`, and is not worth pretending otherwise.
	Version string

	// Revision is the commit, when the toolchain recorded one. Empty for a
	// build made from an unpacked module zip, which carries no repository.
	Revision string

	// Time is the commit time, in RFC 3339, on the same terms as Revision.
	Time string

	// Modified reports that the working tree had uncommitted changes. A true
	// here is why two binaries reporting the same Revision can differ.
	Modified bool

	// Go is the toolchain that built it.
	Go string
}

Info is what a build knows about itself.

func Get

func Get() Info

Get reads this binary's own build information.

func (Info) String

func (i Info) String() string

String is the one-line version, which is what `rig --version` prints and what travels into the compiled document as the tool that produced it.

A development build says so and names the commit, because "dev" alone in a generated file's provenance answers nothing.

Jump to

Keyboard shortcuts

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