Documentation
¶
Index ¶
- Variables
- func Compare(a *Version, b *Version) int
- func FindMaxGeneric[T any](versions []T, getFunc func(x T) *Version, referenceVersion *Version, ...) T
- func Sort(versions []*Version)
- type Version
- func FindMax(versions []*Version, referenceVersion *Version, onlyWithoutStringValues bool) *Version
- func MustParseVersionFromRegex(versionString string, versionRegexp *regexp.Regexp) *Version
- func ParseSimple(parts ...any) *Version
- func ParseVersionFromRegex(versionString string, versionRegexp *regexp.Regexp) (*Version, error)
- func (a *Version) CompareTo(b *Version) int
- func (v *Version) CoreVersion() string
- func (v *Version) DefinedSegmentCount() int
- func (a *Version) Equals(b *Version) bool
- func (a *Version) GreaterThan(b *Version) bool
- func (a *Version) GreaterThanOrEqual(b *Version) bool
- func (a *Version) LessThan(b *Version) bool
- func (a *Version) LessThanOrEqual(b *Version) bool
- func (v *Version) Major() int
- func (v *Version) Minor() int
- func (v *Version) Patch() int
- func (v *Version) SegmentCount(onlyDefined bool) int
- func (v *Version) String() string
- type VersionSegment
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoMatch = errors.New("failed matching")
)
var RegexpSemver *regexp.Regexp = regexp.MustCompile(`^(?P<d1>\d+)\.(?P<d2>\d+)\.(?P<d3>\d+)(?:-(?P<s4>[^+]+))?(?:\+(?P<s5>.*))?$`)
A regex that matches the semantic versioning pattern. d.d.d(-s)(+s)
var RegexpSimple *regexp.Regexp = regexp.MustCompile(`^(?P<d1>\d+)(?:\.(?P<d2>\d+))?(?:\.(?P<d3>\d+))?$`)
A simple regexp that matches one, two or three digits separated by a dot. d(.d)(.d)
Functions ¶
Types ¶
type Version ¶
type Version struct {
// The raw string of the version.
Raw string
// The different segements of the version.
Segments []VersionSegment
// A field for custom data for the version object.
CustomData any
}
Type that represents a version object.
An empty version, can be used to find the max version of a list.
func MustParseVersionFromRegex ¶
Parses the given version string with the regexp into the version object. Throws a panic on error.
func ParseVersionFromRegex ¶
Parses the given version string with the regexp into the version object.
func (*Version) CoreVersion ¶ added in v0.5.1
CoreVersion Converts the version to a core SemVer string in the form major.minor.patch
func (*Version) DefinedSegmentCount ¶ added in v0.8.0
Returns the count of defined segments until an undefined one (or no more).
func (*Version) GreaterThan ¶ added in v0.1.3
func (*Version) GreaterThanOrEqual ¶ added in v0.9.0
func (*Version) LessThanOrEqual ¶ added in v0.9.0
func (*Version) SegmentCount ¶ added in v0.6.0
Returns the total count of the segments, either with undefined or without.
type VersionSegment ¶
A segment of the version, can either be a number or a text.
func (*VersionSegment) IsDefined ¶ added in v0.8.0
func (v *VersionSegment) IsDefined() bool
Returns a boolean if the segment has a defined value or not.
func (*VersionSegment) String ¶
func (v *VersionSegment) String() string
Converts the version segment to a readable string.