semver

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const RegexSemVer = "([0-9]+)\\.([0-9]+)\\.([0-9]+)[-_]?([a-zA-Z0-9\\.]*)\\+?([a-zA-Z0-9]+)?"

RegexSemVer represents version of SevVer format: major.minor.patch-<pre>+<build>

Variables

This section is empty.

Functions

func CheckMaxVersionRequirement

func CheckMaxVersionRequirement(progVersion string, maximum string) error

CheckMaxVersionRequirement checks if a version meets the maximum version requirements

func CheckMinVersionRequirement

func CheckMinVersionRequirement(progVersion string, minimum string) error

CheckMinVersionRequirement checks if a version meets the minimum version requirements

func CheckVersionRequirements

func CheckVersionRequirements(progVersion string, minimum string, maximum string) error

CheckVersionRequirements checks if a version is between the minimum and maximum version if maximum is empty string, it will ignore checking for that version.

Types

type Semver

type Semver struct {
	// contains filtered or unexported fields
}

Semver represents a Semantic Version. It also exposes various version comparison functionalities.

It uses Semantic Versioning specification to handle the version comparison logic.

If a version is not SemVer formatted, it converts that into a SemVer format:

  • "219" will be converted into 219.0.0 internally.
  • "v1.2" will be converted to "1.2.0" internally.
  • "8.30" will be converted to "8.30.0" internally.

preRelease part of the version is compared lexicographically for simplicity of implementation. The reason for such trade-off is we only expect proper released version of the software to be installed on the nodes. However, if there is a preRelease-release part in the version, it will be considered lower precedence if major, minor, and patch are equal, which adheres to spec https://semver.org/#spec-item-11. If both versions have preRelease-release part, preRelease parts are compared lexicographically.

func NewSemver

func NewSemver(v string) (Semver, error)

NewSemver parses and returns an instance of Semver if parsing of the input version string is successful

func (*Semver) EqualTo

func (v *Semver) EqualTo(v2 Semver) bool

EqualTo checks if it is equal to the input version It performs a string comparison of the raw in full.

func (*Semver) GreaterOrEqual

func (v *Semver) GreaterOrEqual(v2 Semver) bool

GreaterOrEqual return true if it is greater than or equal to the input version v2 This is just a wrapper function around GreaterThan and EqualTo

func (*Semver) GreaterThan

func (v *Semver) GreaterThan(v2 Semver) bool

GreaterThan checks if it is greater than the input version v2 Ref: https://semver.org/#spec-item-11

func (*Semver) LessOrEqual

func (v *Semver) LessOrEqual(v2 Semver) bool

LessOrEqual return true if it is less than or equal to the input version v2 This is just a wrapper function around LessThan and EqualTo

func (*Semver) LessThan

func (v *Semver) LessThan(v2 Semver) bool

LessThan checks if it is less than the input version v2 Ref: https://semver.org/#spec-item-11

func (*Semver) Raw

func (v *Semver) Raw() string

Raw returns the input version string

Jump to

Keyboard shortcuts

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