version

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 5 Imported by: 0

README

This code adapted from https://github.com/blang/semver

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(v Version) bool

func MakeEqualsFull

func MakeEqualsFull(this Version) func(other Version) bool

func MakeEqualsMajor

func MakeEqualsMajor(this Version) func(other Version) bool

func MakeEqualsMajorMinor

func MakeEqualsMajorMinor(this Version) func(other Version) bool

func MakeGTE

func MakeGTE(this Version) func(other Version) bool

func MakeLTE

func MakeLTE(this Version) func(other Version) bool

func None

func None(v Version) bool

Types

type Range

type Range func(Version) bool

Range represents a range of versions. A Range can be used to check if a Version satisfies it:

range, err := semver.ParseRange(">1.0.0 <2.0.0")
range(semver.MustParse("1.1.1") // returns true

func MustParseRange

func MustParseRange(s string) Range

MustParseRange is like ParseRange but panics if the range cannot be parsed.

func ParseRange

func ParseRange(s string) (Range, error)

ParseRange parses a range and returns a Range. If the range could not be parsed an error is returned.

Valid ranges are:

  • "<1.0.0"
  • "<=1.0.0"
  • ">1.0.0"
  • ">=1.0.0"
  • "1.0.0", "=1.0.0", "==1.0.0"
  • "!1.0.0", "!=1.0.0"

A Range can consist of multiple ranges separated by space: Ranges can be linked by logical AND:

  • ">1.0.0 <2.0.0" would match between both ranges, so "1.1.1" and "1.8.7" but not "1.0.0" or "2.0.0"
  • ">1.0.0 <3.0.0 !2.0.3-beta.2" would match every version between 1.0.0 and 3.0.0 except 2.0.3-beta.2

Ranges can also be linked by logical OR:

  • "<2.0.0 || >=3.0.0" would match "1.x.x" and "3.x.x" but not "2.x.x"

AND has a higher precedence than OR. It's not possible to use brackets.

Ranges can be combined by both AND and OR

  • `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1`

func (Range) AND

func (rf Range) AND(f Range) Range

AND combines the existing Range with another Range using logical AND.

func (Range) OR

func (rf Range) OR(f Range) Range

OR combines the existing Range with another Range using logical OR.

type Version

type Version struct {
	Major uint64
	Minor uint64
	Patch uint64
}

func MustParse

func MustParse(s string) Version

MustParse is like Parse but panics if the version cannot be parsed.

func Parse

func Parse(s string) (Version, error)

Parse parses version string and returns a validated Version or error

func (Version) Compare

func (v Version) Compare(o Version) int

Compare compares Versions v to o: -1 == v is less than o 0 == v is equal to o 1 == v is greater than o

func (Version) EQ

func (v Version) EQ(o Version) bool

EQ checks if v is equal to o.

func (Version) Equals

func (v Version) Equals(o Version) bool

Equals checks if v is equal to o.

func (Version) GE

func (v Version) GE(o Version) bool

GE checks if v is greater than or equal to o.

func (Version) GT

func (v Version) GT(o Version) bool

GT checks if v is greater than o.

func (Version) GTE

func (v Version) GTE(o Version) bool

GTE checks if v is greater than or equal to o.

func (Version) LE

func (v Version) LE(o Version) bool

LE checks if v is less than or equal to o.

func (Version) LT

func (v Version) LT(o Version) bool

LT checks if v is less than o.

func (Version) LTE

func (v Version) LTE(o Version) bool

LTE checks if v is less than or equal to o.

func (Version) NE

func (v Version) NE(o Version) bool

NE checks if v is not equal to o.

Jump to

Keyboard shortcuts

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