Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
CompareVersions robustly compares two version strings. It leverages UniRTM's comprehensive internal Version parser to handle semver, date-versions, and aliases (like "latest" vs "lts"). If one or both versions fail to parse (e.g. non-standard alphanumeric directories like "tip"), it falls back to a segment-based numerical splitting algorithm to gracefully handle any string format. Returns:
1 if v1 > v2
-1 if v1 < v2
0 if v1 == v2
func FormatVersion ¶
FormatVersion formats a Version object back into a version string
Types ¶
type RangeOperator ¶
type RangeOperator string
RangeOperator represents the operator in a version range
const ( // RangeOperatorGTE represents ">=" (greater than or equal) RangeOperatorGTE RangeOperator = ">=" // RangeOperatorGT represents ">" (greater than) RangeOperatorGT RangeOperator = ">" // RangeOperatorLTE represents "<=" (less than or equal) RangeOperatorLTE RangeOperator = "<=" // RangeOperatorLT represents "<" (less than) RangeOperatorLT RangeOperator = "<" // RangeOperatorEQ represents "=" (equal) RangeOperatorEQ RangeOperator = "=" // RangeOperatorCaret represents "^" (compatible with) RangeOperatorCaret RangeOperator = "^" // RangeOperatorTilde represents "~" (approximately equivalent to) RangeOperatorTilde RangeOperator = "~" )
type SemVer ¶
type SemVer struct {
Major int
Minor int
Patch int
Prerelease string // e.g., "alpha.1", "beta.2", "rc.1"
Build string // e.g., "20130313144700"
}
SemVer represents a semantic version
func ParseSemVer ¶
ParseSemVer parses a semantic version string into a SemVer struct
func ParseSemVerPartial ¶
ParseSemVerPartial parses a partial semantic version string (for tilde ranges) Supports: 1, 1.2, 1.2.3, 1.2.3-alpha, etc.
type Version ¶
type Version struct {
Type VersionType
// For VersionTypeExact
Exact *SemVer
// For VersionTypeRange
RangeOp RangeOperator
RangeVer *SemVer
// For VersionTypeAlias
Alias VersionAlias
}
Version represents a version specification
func ParseVersion ¶
ParseVersion parses a version string into a Version object
type VersionAlias ¶
type VersionAlias string
VersionAlias represents known version aliases
const ( // VersionAliasLatest represents the latest version VersionAliasLatest VersionAlias = "latest" // VersionAliasLTS represents the latest LTS version VersionAliasLTS VersionAlias = "lts" // VersionAliasStable represents the latest stable version VersionAliasStable VersionAlias = "stable" )
type VersionType ¶
type VersionType int
VersionType represents the type of version specification
const ( // VersionTypeExact represents an exact semver version (e.g., "1.20.0") VersionTypeExact VersionType = iota // VersionTypeRange represents a version range (e.g., ">=1.20.0", "^3.11", "~2.7.0") VersionTypeRange // VersionTypeAlias represents a version alias (e.g., "latest", "lts", "stable") VersionTypeAlias )