version

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "unknown"
	Commit    = "unknown"
	BuildDate = "unknown"
)

Build-time variables set via -ldflags

Functions

func Branch added in v0.2.1

func Branch() string

Branch returns the release channel this binary was built from: the tag name for tagged releases (e.g. "v0.2.0"), the branch name for branch builds (e.g. "main" for "main:abc123"), and empty for unknown versions. See BranchOf.

func BranchOf added in v0.16.0

func BranchOf(v string) string

BranchOf derives the release channel from a version string as produced by hack/build.sh. A detached checkout reports its branch as "HEAD", which is not a channel anything publishes under; it is treated as "main" so installers pick the main image and release bundle rather than failing on a channel named HEAD.

Types

type Info

type Info struct {
	Version   string    `json:"version"`
	Commit    string    `json:"commit"`
	BuildDate time.Time `json:"build_date"`
}

Info represents version information

func GetInfo

func GetInfo() Info

GetInfo returns the current version information

func (Info) IsNewer

func (i Info) IsNewer(other Info) bool

IsNewer returns true if this version info is newer than the other

func (Info) JSON

func (i Info) JSON() (string, error)

JSON returns the version info as JSON

func (Info) KnownCommit added in v0.16.0

func (i Info) KnownCommit() string

KnownCommit returns the commit this binary was built from, or "" when the build did not stamp one. Commit's zero value is the literal "unknown", which is fine to print but must not travel anywhere a missing commit means something.

func (Info) String

func (i Info) String() string

String returns the version info as a formatted string

Jump to

Keyboard shortcuts

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