Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constraint ¶
type Constraint struct {
Type ConstraintType
Version *Version
}
Constraint represents a parsed version constraint.
func ParseConstraint ¶
func ParseConstraint(s string) (*Constraint, error)
ParseConstraint parses a version constraint string. Supported formats: "1.0.0", "^1.0.0", "~1.0.0"
func (*Constraint) FindBestMatch ¶
func (c *Constraint) FindBestMatch(versions []*Version) *Version
FindBestMatch finds the best (highest) matching version from a list. Returns nil if no version matches the constraint.
func (*Constraint) IsExact ¶
func (c *Constraint) IsExact() bool
IsExact returns true if this is an exact version constraint.
func (*Constraint) Matches ¶
func (c *Constraint) Matches(v *Version) bool
Matches returns true if the given version satisfies this constraint.
func (*Constraint) String ¶
func (c *Constraint) String() string
String returns the string representation of the constraint.
type ConstraintType ¶
type ConstraintType int
ConstraintType identifies the type of version constraint.
const ( // ConstraintExact matches only the exact version (e.g., "1.0.0"). ConstraintExact ConstraintType = iota // ConstraintCaret matches minor-compatible versions (e.g., "^1.0.0" matches >=1.0.0, <2.0.0). ConstraintCaret // ConstraintTilde matches patch-compatible versions (e.g., "~1.0.0" matches >=1.0.0, <1.1.0). ConstraintTilde )
type Version ¶
Version represents a parsed semantic version.
func (*Version) Compare ¶
Compare returns -1 if v < other, 0 if v == other, 1 if v > other. Prerelease versions are considered less than release versions with the same major.minor.patch.
func (*Version) GreaterThanOrEqual ¶
GreaterThanOrEqual returns true if v >= other.