Documentation
¶
Overview ¶
Package version provides version parsing helpers shared by clive and its subpackages. It wraps hashicorp/go-version with prefix stripping, dev-version detection, and natural-sort prerelease comparison.
Index ¶
- func AddPrefix(v string) string
- func CommitCount(v string) int
- func Compare(a, b *goversion.Version) int
- func Equal(a, b *goversion.Version) bool
- func ExtractBase(v string) string
- func GreaterThan(a, b *goversion.Version) bool
- func HasPrefix(v string) bool
- func IsDev(v string) bool
- func LessThan(a, b *goversion.Version) bool
- func Parse(v string) (*goversion.Version, error)
- func RemovePrefix(v string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitCount ¶
CommitCount returns the number of commits since the last tag embedded in a git-describe-formatted version string (e.g. "v1.2.3-4-gabcdef[-dev]"), or 0.
func Compare ¶
Compare orders two versions, using natural sort for prerelease tags so e.g. "rc2" < "rc10". Nil sorts before non-nil; two nils are equal.
func ExtractBase ¶
ExtractBase recovers the underlying release version from a dev version.
Examples:
- "0.20.8-2-g55ae225" -> "0.20.8"
- "0.21.3-2-g55ae225-dev" -> "0.21.3"
- "0.21.3-3b71351-dev" -> "0.21.3"
For non-dev inputs the v-prefix is stripped and the rest returned as-is.
func GreaterThan ¶
GreaterThan reports whether a > b.
func IsDev ¶
IsDev reports whether v looks like a development build.
Two formats are recognised:
- git describe: vX.Y.Z-N-gHASH (N commits ahead of tag X.Y.Z)
- dev suffix: vX.Y.Z-HASH-dev or vX.Y.Z-N-gHASH-dev
Both indicate commits AHEAD of a tagged release, not prereleases.
func Parse ¶
Parse normalizes and parses a version string into a goversion.Version. It strips a "v" prefix and drops anything after a "-g<hash>" git suffix; go-version pads versions with fewer than three components ("1.2" -> "1.2.0").
func RemovePrefix ¶
RemovePrefix strips a leading "v"/"V" if present.
Types ¶
This section is empty.