cmpver

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(ver1 string, op Operation, ver2 string) (bool, error)

Compare compare ver1 and ver2 by operation

For example:

Compare(ver1, Greater, ver2) is same as "ver1 > ver2"

Dirty versions and pre versions are regarded as standard version. For example: 'v5.1.2-dev' and 'v5.1.2-betav1' are regarded as 'v5.1.2'.

Latest, nightly or master version is larger than any version

func CompareByStr

func CompareByStr(ver1, opstr, ver2 string) (bool, error)

CompareByStr compare ver1 and ver2

For example:

CompareByStr(ver1, ">", ver2) is same as "ver1 > ver2"

Dirty versions and pre versions are regarded as standard version. For example: 'v5.1.2-dev' and 'v5.1.2-betav1' are regarded as 'v5.1.2'.

Latest, nightly or master version is larger than any version

Types

type Constraint

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

func NewConstraint

func NewConstraint(op Operation, version string) (*Constraint, error)

func (*Constraint) Check

func (c *Constraint) Check(version string) (bool, error)

Check tests if a version satisfies the constraints.

Dirty versions and pre versions are regarded as standard version. For example: 'v5.1.2-dev' and 'v5.1.2-betav1' are regarded as 'v5.1.2'.

Latest, nightly or master version is larger than any version

type Operation

type Operation string
const (
	Greater        Operation = ">"
	GreaterOrEqual Operation = ">="
	Less           Operation = "<"
	LessOrEqual    Operation = "<="
)

Jump to

Keyboard shortcuts

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