Documentation ¶
Index ¶
- Variables
- type Collection
- type ConstraintOption
- type Constraints
- type Version
- func (v Version) CaretBump() Version
- func (v Version) Compare(o Version) int
- func (v Version) Equal(o Version) bool
- func (v Version) GreaterThan(o Version) bool
- func (v Version) GreaterThanOrEqual(o Version) bool
- func (v Version) IncMajor() Version
- func (v Version) IncMinor() Version
- func (v Version) IncPatch() Version
- func (v Version) IsAny() bool
- func (v Version) IsPreRelease() bool
- func (v Version) LessThan(o Version) bool
- func (v Version) LessThanOrEqual(o Version) bool
- func (v Version) Major() part.Part
- func (v Version) Metadata() string
- func (v Version) Min() Version
- func (v Version) Minor() part.Part
- func (v Version) Original() string
- func (v Version) Patch() part.Part
- func (v Version) PreRelease() part.Parts
- func (v Version) Release() Version
- func (v Version) String() string
- func (v Version) TildeBump() Version
- type WithPreRelease
- type WithZeroPadding
Constants ¶
This section is empty.
Variables ¶
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 (Version) CaretBump ¶
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 ¶
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 ¶
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 ¶
GreaterThan tests if one version is greater than another one.
func (Version) GreaterThanOrEqual ¶
GreaterThanOrEqual tests if this version is greater than or equal to another version.
func (Version) IsPreRelease ¶
IsPreRelease returns if it is a pre-release version. 1.2.3 => false 1.2.3-alpha => true
func (Version) LessThanOrEqual ¶
LessThanOrEqual tests if this version is less than or equal to another version.
func (Version) Min ¶
Min produces the minimum version if it includes wild card. 1.2.* => 1.2.0 1.*.* => 1.0.0
func (Version) PreRelease ¶
PreRelease returns the pre-release version.
func (Version) TildeBump ¶
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