semver

package
v0.0.0-...-637058c Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 8 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidSemVer is returned when a given version is invalid
	ErrInvalidSemVer = xerrors.New("invalid semantic version")
)

Functions

This section is empty.

Types

type Collection

type Collection []Version

Collection is a type that implements the sort.Interface interface so that versions can be sorted.

func (Collection) Len

func (v Collection) Len() int

func (Collection) Less

func (v Collection) Less(i, j int) bool

func (Collection) Swap

func (v Collection) Swap(i, j int)

type ConstraintOption

type ConstraintOption interface {
	// contains filtered or unexported methods
}

type Constraints

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

func NewConstraints

func NewConstraints(v string, opts ...ConstraintOption) (Constraints, error)

NewConstraints parses a given constraint and returns a new instance of Constraints

func (Constraints) Check

func (cs Constraints) Check(v Version) bool

Check tests if a version satisfies all the constraints.

func (Constraints) String

func (cs Constraints) String() string

Returns the string format of the constraints

type Version

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

Version represents a semantic version.

func New

func New(major, minor, patch part.Part, pre part.Parts, metadata string) Version

New returns an instance of Version

func Parse

func Parse(v string) (Version, error)

Parse parses a given version and returns a new instance of Version

func (Version) CaretBump

func (v Version) CaretBump() Version

CaretBump returns the maximum version of caret ranges e.g. ^1.2.3 := >=1.2.3 <2.0.0 In this case, it returns 2.0.0 ref. https://docs.npmjs.com/cli/v6/using-npm/semver#caret-ranges-123-025-004

func (Version) Compare

func (v Version) Compare(o Version) int

Compare compares this version to another one. It returns -1, 0, or 1 if the version smaller, equal, or larger than the other version.

Versions are compared by X.Y.Z. Build metadata is ignored. Prerelease is lower than the version without a prerelease.

func (Version) Equal

func (v Version) Equal(o Version) bool

Equal tests if two versions are equal to each other. Note, versions can be equal with different metadata since metadata is not considered part of the comparable version.

func (Version) GreaterThan

func (v Version) GreaterThan(o Version) bool

GreaterThan tests if one version is greater than another one.

func (Version) GreaterThanOrEqual

func (v Version) GreaterThanOrEqual(o Version) bool

GreaterThanOrEqual tests if this version is greater than or equal to another version.

func (Version) IncMajor

func (v Version) IncMajor() Version

IncMajor produces the next major version. e.g. 1.2.3 => 2.0.0

func (Version) IncMinor

func (v Version) IncMinor() Version

IncMinor produces the next minor version.

func (Version) IncPatch

func (v Version) IncPatch() Version

IncPatch produces the next patch version.

func (Version) IsAny

func (v Version) IsAny() bool

IsAny returns true if major, minor or patch is wild card

func (Version) IsPreRelease

func (v Version) IsPreRelease() bool

IsPreRelease returns if it is a pre-release version. 1.2.3 => false 1.2.3-alpha => true

func (Version) LessThan

func (v Version) LessThan(o Version) bool

LessThan tests if one version is less than another one.

func (Version) LessThanOrEqual

func (v Version) LessThanOrEqual(o Version) bool

LessThanOrEqual tests if this version is less than or equal to another version.

func (Version) Major

func (v Version) Major() part.Part

Major returns the major version.

func (Version) Metadata

func (v Version) Metadata() string

Metadata returns the metadata on the version.

func (Version) Min

func (v Version) Min() Version

Min produces the minimum version if it includes wild card. 1.2.* => 1.2.0 1.*.* => 1.0.0

func (Version) Minor

func (v Version) Minor() part.Part

Minor returns the minor version.

func (Version) Original

func (v Version) Original() string

Original returns the original value.

func (Version) Patch

func (v Version) Patch() part.Part

Patch returns the patch version.

func (Version) PreRelease

func (v Version) PreRelease() part.Parts

PreRelease returns the pre-release version.

func (Version) Release

func (v Version) Release() Version

Release returns the version without pre-release. e.g. 1.2.3-alpha => 1.2.3

func (Version) String

func (v Version) String() string

String converts a Version object to a string.

func (Version) TildeBump

func (v Version) TildeBump() Version

TildeBump returns the maximum version of tilde ranges e.g. ~1.2.3 := >=1.2.3 <1.3.0 In this case, it returns 1.3.0 ref. https://docs.npmjs.com/cli/v6/using-npm/semver#tilde-ranges-123-12-1

type WithPreRelease

type WithPreRelease bool

type WithZeroPadding

type WithZeroPadding bool

Jump to

Keyboard shortcuts

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