version

package
v0.0.0-...-e0271d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package version provides support for semantic versions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareReleaseVersions

func CompareReleaseVersions(versionA, versionB string) int

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

func CompareReleaseVersionsOr(versionA, versionB string, incomparableRes int) int

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

func CompareVersions(versionA, versionB string) int

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

func CompareVersionsOr(versionA, versionB string, incomparableRes int) int

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

func LatestVersion(versions []string) (string, error)

LatestVersion returns the latest version from a list of unsorted semantic versions.

func Validate

func Validate(version string) error

Validate returns no error if the given version is a valid version in the context of the service.

Types

type ByVersion

type ByVersion []string

ByVersion implements sort.Interface based on the version information.

func (ByVersion) Len

func (versions ByVersion) Len() int

func (ByVersion) Less

func (versions ByVersion) Less(i, j int) bool

func (ByVersion) Swap

func (versions ByVersion) Swap(i, j int)

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
)

func GetKind

func GetKind(versionStr string) Kind

GetKind returns the version kind (release, RC, development) of the given version string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL