Documentation
¶
Overview ¶
Example ¶
var v1 = "v1.1.0"
var v2 = "1.0.4"
var invalid = ".1.0"
vers1, err := version.Parse(v1)
if err != nil {
fmt.Printf("could not parse version %q", v1)
}
vers2, err := version.Parse(v2)
if err != nil {
fmt.Printf("could not parse version %q", v1)
}
if vers2.Less(*vers1) {
fmt.Printf("version %s < version %s\n", vers2, vers1)
}
vers2.Minor = 1
if vers1.Less(*vers2) {
fmt.Printf("version %s < version %s\n", vers1, vers2)
}
last := version.Versions{vers1, vers2}.Sort().Last()
fmt.Printf("last version is %s\n", last)
_, err = version.Parse(invalid)
if err != nil {
fmt.Printf("could not parse version %q", invalid)
}
Output: version 1.0.4 < version 1.1.0 version 1.1.0 < version 1.1.4 last version is 1.1.4 could not parse version ".1.0"
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Version ¶
Version represents a version (e.g. a release version)
func BuildVersion ¶
func BuildVersion() (v *Version)
func Parse ¶
Parse parses the version out of the given string. Valid strings are "v0.0.1" or "1.0" or "12" etc.
func V ¶
V is a helper function to create Versions without a Rest with little effort. The first and obligatory is the major number. No more than two following numbers can be passed, otherwise the function panics. The following numbers are minor and patch. If just one following number is given, it is considered the minor number and patch will be 0. If just the major number is given, minor and patch will be 0
func (Version) EqualsMajor ¶
EqualsMajor is true when the version equals the given version on the Major
func (Version) EqualsMinor ¶
EqualsMinor is true when the version equals the given version on the Major and Minor
func (Version) EqualsPatch ¶
EqualsPatch is true when the version equals the given version on the Major and Minor and Patch
type Versions ¶
type Versions []*Version
Versions is a sortable slice of *Version