semver

package
v0.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SpecVersion = Version{
	Major: 2,
	Minor: 0,
	Patch: 0,
}

SpecVersion is the latest fully supported spec version of semver

Functions

func NewBuildVersion

func NewBuildVersion(s string) (string, error)

NewBuildVersion creates a new valid build version

Types

type PRVersion

type PRVersion struct {
	VersionStr string
	VersionNum uint64
	IsNum      bool
}

PRVersion represents a PreRelease Version

func NewPRVersion

func NewPRVersion(s string) (PRVersion, error)

NewPRVersion creates a new valid prerelease version

func (PRVersion) Compare

func (v PRVersion) Compare(o PRVersion) int

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

func (PRVersion) IsNumeric

func (v PRVersion) IsNumeric() bool

IsNumeric checks if prerelease-version is numeric

func (PRVersion) String

func (v PRVersion) String() string

PreRelease version to string

type Version

type Version struct {
	Major  uint64
	Minor  uint64
	Patch  uint64
	Pre    []PRVersion
	Build  []string //No Precedence
	Prefix string
}

Version represents a semver compatible version

func Make

func Make(s string) (Version, error)

Make is an alias for Parse, parses version string and returns a validated Version or error

func MustParse

func MustParse(s string) Version

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

func New

func New(s string) (vp *Version, err error)

New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error

func Parse

func Parse(s string) (Version, error)

Parse parses version string and returns a validated Version or error

func ParseTolerant

func ParseTolerant(s string) (Version, error)

ParseTolerant allows for certain version specifications that do not strictly adhere to semver specs to be parsed by this library. It does so by normalizing versions before passing them to Parse(). It currently trims spaces, adds a 0 patch number to versions with only major and minor components specified, and removes leading 0s.

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) IncrementMajor

func (v *Version) IncrementMajor() error

IncrementMajor increments the major version

func (*Version) IncrementMinor

func (v *Version) IncrementMinor() error

IncrementMinor increments the minor version

func (*Version) IncrementPatch

func (v *Version) IncrementPatch() error

IncrementPatch increments the patch version

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.

func (Version) String

func (v Version) String() string

Version to string

func (Version) Validate

func (v Version) Validate() error

Validate validates v and returns error in case

Jump to

Keyboard shortcuts

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