Documentation ¶
Overview ¶
Package version provides support for semantic versions.
Index ¶
- func CompareReleaseVersions(versionA, versionB string) int
- func CompareReleaseVersionsOr(versionA, versionB string, incomparableRes int) int
- func CompareVersions(versionA, versionB string) int
- func CompareVersionsOr(versionA, versionB string, incomparableRes int) int
- func LatestVersion(versions []string) (string, error)
- func Validate(version string) error
- type ByVersion
- type Kind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareReleaseVersions ¶
CompareReleaseVersions compares the two versions, which must be release versions, and returns -1 if versionA is DEFINITELY a lower version than versionB, or 1 if versionA is DEFINITELY a greater version than versionB. It returns 0 unless both versions are release versions.
func CompareReleaseVersionsOr ¶
CompareReleaseVersionsOr compares the two versions if both of them are release versions. If at least one of the versions is not a release versions, they are incomparable UNLESS they are exactly the same, and if they're not exactly the same, the result specified as incomparableRes is returned. Otherwise, a result of < 0 is returned if versionA is lower than versionB, a result of > 0 is returned if versionA is higher than versionB, and 0 is returned if both versions are equal.
func CompareVersions ¶
CompareVersions compares the two versions and returns -1 if versionA is a lower version than versionB or 1 if version A is a greater version than versionB. It returns 0 if they are not comparable.
func CompareVersionsOr ¶
CompareVersionsOr compares the two versions and returns -1 if versionA is a lower version than versionB or 1 if version A is a greater version than versionB. It returns incomparableRes if they are not comparable.
func LatestVersion ¶
LatestVersion returns the latest version from a list of unsorted semantic versions.
Types ¶
type ByVersion ¶
type ByVersion []string
ByVersion implements sort.Interface based on the version information.
type Kind ¶
type Kind int
Kind indicates the kind of a version string (development, RC, or release).
const ( // InvalidKind is the version kind for unrecognized version strings. InvalidKind Kind = iota // DevelopmentKind is the version kind for development version strings. DevelopmentKind // RCKind is the version kind for RC version strings. RCKind // ReleaseKind is the version kind for release version strings. ReleaseKind // NightlyKind is the version kind for nightly release version strings. NightlyKind )