Documentation
¶
Overview ¶
Package version exposes the current Dagger build's version, commit, and dirty state.
The semantic version is the contents of the VERSION file at the package root, embedded at compile time via //go:embed.
Commit and dirty state come from runtime/debug build info, wrapped by github.com/dagger/go/buildinfo. Native `go build` outside the Dagger sandbox gets these for free from the toolchain's VCS detection. Sandboxed Dagger builds inject them via -ldflags into buildinfo's Injected* vars.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Commit string
Commit is the VCS commit hash this binary was built from, or "" if unknown.
var CommitTime string
CommitTime is the commit time as RFC3339, or "" if unknown.
var Dirty bool
Dirty reports whether the source tree was modified at build time.
Functions ¶
func CommitState ¶
func CommitState() string
CommitState returns the short VCS revision, with "+dirty" appended when the source tree had modifications at build time.
func ShortCommit ¶
func ShortCommit() string
ShortCommit returns the short VCS revision used in human-readable version output, or "" if the build's revision is unknown.
func Version ¶
Version returns this build's semantic version. By default it is bare ("0.21.3"); options add the "v" prefix and/or commit provenance:
Version() "0.21.3" Version(WithV()) "v0.21.3" Version(WithCommit()) "0.21.3+42424242" (or +….dirty) Version(WithV(), WithCommit()) "v0.21.3+42424242"
It is the single accessor for the version string; the underlying value is unexported so the "v"-prefix choice is always explicit at the call site. The commit is truncated to 8 characters; use Commit directly for the full hash.
Types ¶
type Opt ¶
type Opt func(*options)
Opt configures the string returned by Version.
func WithCommit ¶
func WithCommit() Opt
WithCommit appends the short VCS commit, plus a ".dirty" marker when the source tree was modified, when the commit is known (e.g. "0.21.3+42424242.dirty"). It is a no-op when the commit is unknown.