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 ...interface{}) *Version
- func ParseVersionFromRegex(versionString string, versionRegexp *regexp.Regexp) (*Version, error)
- func (a *Version) CompareTo(b *Version) int
- func (v *Version) CoreVersion() string
- func (a *Version) Equals(b *Version) bool
- func (a *Version) GreaterThan(b *Version) bool
- func (a *Version) LessThan(b *Version) bool
- func (v *Version) Major() int
- func (v *Version) Minor() int
- func (v *Version) Patch() int
- func (v *Version) String() string
- type VersionSegment
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoMatch = errors.New("failed matching")
)
View Source
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)
View Source
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 ¶
func FindMaxGeneric ¶ added in v0.4.0
Types ¶
type Version ¶
type Version struct { Raw string Segments []VersionSegment }
Type that represents a version object.
An empty version, can be used to find the max version of a list.
func ParseSimple ¶
func ParseSimple(parts ...interface{}) *Version
Parses the given parts into a version.
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.path
func (*Version) GreaterThan ¶ added in v0.1.3
type VersionSegment ¶
A segment of the version, can either be a number or a text.
func (*VersionSegment) String ¶
func (v *VersionSegment) String() string
Converts the version segment to a readable string.
Click to show internal directories.
Click to hide internal directories.