Documentation
¶
Overview ¶
Package buildinfo resolves what a binary reports about its own build: the version, commit, build time and Go version. The linker's -X stamps win when a build passed them (the Makefile and the release build do); otherwise the module version and VCS metadata the Go toolchain embeds stand in, which is what a `go install` build has; and a build with neither reports the defaults.
Index ¶
Constants ¶
const ( // Unversioned is the version of a build no release tag identifies. Unversioned = "dev" // Unknown is a commit, build time or Go version nothing recorded. Unknown = "unknown" // Dirty is appended to the commit of a build from a modified working tree, // as `git describe --dirty` appends it to the Makefile's version. Dirty = "-dirty" )
Variables ¶
This section is empty.
Functions ¶
func Released ¶
Released reports whether a module version names a release tag: one the toolchain stamped that is a semantic version and not a pseudo-version, which identifies a commit rather than a release.
func ShortRevision ¶
ShortRevision abbreviates a commit hash to the length it is reported at.
Types ¶
type Info ¶
type Info struct {
// Version is the release tag the build is of, or Unversioned.
Version string
// Commit is the short commit hash, Dirty appended for a modified tree, or Unknown.
Commit string
// BuildTime is when the build happened, or the commit's time when only that
// is recorded, in the Makefile's format; Unknown when neither is.
BuildTime string
// GoVersion is the toolchain that built the binary.
GoVersion string
}
Info is what a binary reports about its build.
func Resolve ¶
Resolve reports the running binary's build from stamps and the build information the toolchain embedded in it.
func ResolveFrom ¶
ResolveFrom reports a build from stamps and the build information embedded in it, which may be nil for a binary the toolchain recorded nothing about. A stamp that is set wins; what the build information says fills the rest.