Categorygithub.com/k0sproject/version
modulepackage
0.6.0
Repository: https://github.com/k0sproject/version.git
Documentation: pkg.go.dev

# README

version

A go-language package for managing k0s version numbers. It is based on hashicorp/go-version but adds sorting and comparison capabilities for the k0s version numbering scheme which requires additional sorting by the build tag.

Usage

Basic comparison

import (
	"fmt"
	"github.com/k0sproject/version"
)

func main() {
	a := version.MustParse("1.23.3+k0s.1")
	b := version.MustParse("1.23.3+k0s.2")
	fmt.Printf("a is greater than b: %t\n", a.GreaterThan(b))
	fmt.Printf("a is less than b: %t\n", a.LessThan(b))
	fmt.Printf("a is equal to b: %t\n", a.Equal(b))
}

Outputs:

a is greater than b: false
a is less than b: true
a is equal to b: false

Check online for latest version

import (
	"fmt"
	"github.com/k0sproject/version"
)

func main() {
	latest, err := version.Latest()
	if err != nil {
		panic(err)
	}
	fmt.Printf("Latest k0s version is: %s\n", latest)
}

k0s_sort executable

A command-line interface to the package. Can be used to sort lists of versions or to obtain the latest version number.

Usage: k0s_sort [options] [filename ...]
  -l	only print the latest version
  -o	print the latest version from online
  -s	omit prerelease versions
  -v	print k0s_sort version

# Packages

No description provided by the author

# Functions

LatestVersion returns the semantically sorted latest version even if it is a prerelease from the online repository.
LatestByPrerelease returns the latest released k0s version, if preok is true, prereleases are also accepted.
LatestStable returns the semantically sorted latest non-prerelease version from the online repository.
MustConstraint is like NewConstraint but panics if the constraint is invalid.
MustParse is like NewVersion but panics if the version cannot be parsed.
No description provided by the author
NewConstraint parses a string into a Constraints object that can be used to check if a given version satisfies the constraint.
NewVersion returns a new Version created from the supplied string or an error if the string is not a valid version number.

# Variables

No description provided by the author
No description provided by the author

# Structs

Version is a k0s version.

# Type aliases

Collection is a type that implements the sort.Interface interface so that versions can be sorted.
Constraints is a collection of version constraint rules that can be checked against a version.