Documentation
¶
Overview ¶
Package version provides semantic version parsing, comparison, and development-build detection via the [Version] interface. Build-time version strings injected via ldflags are parsed into structured values for display and update-check comparison.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
CompareVersions returns an integer comparing two versions according to semantic version precedence.
func FormatVersionString ¶
FormatVersionString adds or removes a "v" prefix from version string.
func IsReleaseTag ¶ added in v0.49.0
IsReleaseTag reports whether v names a release as tags are written: v-prefixed, three-part, optionally a prerelease. Canonical refuses the shorthands (v1, v1.2) and build metadata that IsValid alone accepts.
Types ¶
type Info ¶
type Info struct {
Version string `json:"version" yaml:"version"`
Commit string `json:"commit" yaml:"commit"`
Date string `json:"date" yaml:"date"`
}
Info holds a build's version information. Its zero value means the binary was not stamped; see IsZero.
func (Info) GetVersion ¶
func (Info) IsDevelopment ¶
IsDevelopment reports whether this is not a release build: an invalid version, a Go pseudo-version (what go build and go install ...@main stamp from a commit), a prerelease carrying a dev or dirty segment, or any build metadata (a VCS-stamped module build reports the tag plus "+dirty").