version

package
v0.0.0-...-d619d40 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowLocalSpecifier

type AllowLocalSpecifier bool

AllowLocalSpecifier is an option that allows local version labels in specifiers. By default (PEP 440), local versions are not permitted in specifiers and local version labels are ignored when checking if candidate versions match a given specifier. When enabled, specifiers like ">= 1.0+local.1" become valid and local version segments are compared strictly.

type SpecifierOption

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

type Specifiers

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

func NewSpecifiers

func NewSpecifiers(v string, opts ...SpecifierOption) (Specifiers, error)

NewSpecifiers parses a given specifier and returns a new instance of Specifiers

func (Specifiers) Check

func (ss Specifiers) Check(v Version) bool

Check tests if a version satisfies all the specifiers.

func (Specifiers) String

func (ss Specifiers) String() string

String returns the string format of the specifiers

func (Specifiers) ToVersionRange

func (ss Specifiers) ToVersionRange() (versionrange.Range[Version], error)

ToVersionRange lowers the specifiers to the generic versionrange model, enabling cross-ecosystem range algebra (Intersect, Union, Complement).

Specifiers with an explicit local version ("==1.0+local") and ">" specifiers whose version is not a post-release cannot be represented: PEP 440's post-release exclusion for ">" is not a contiguous interval. "~=" is only supported for plain release versions.

type Version

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

Version represents a single version.

func MustParse

func MustParse(v string) Version

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

func Parse

func Parse(v string) (Version, error)

Parse parses the given version and returns a new Version.

func (Version) BaseVersion

func (v Version) BaseVersion() string

BaseVersion returns the base version

func (Version) Compare

func (v Version) Compare(other Version) int

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

func (Version) Equal

func (v Version) Equal(o Version) bool

Equal tests if two versions are equal.

func (Version) GreaterThan

func (v Version) GreaterThan(o Version) bool

GreaterThan tests if this version is greater than another version.

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

func (v Version) IsPostRelease() bool

IsPostRelease returns if it is a post-release

func (Version) IsPreRelease

func (v Version) IsPreRelease() bool

IsPreRelease returns if it is a pre-release

func (Version) LessThan

func (v Version) LessThan(o Version) bool

LessThan tests if this version is less than another version.

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

func (v Version) Local() string

Local returns the local version

func (Version) MarshalText

func (v Version) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Version) Original

func (v Version) Original() string

Original returns the original parsed version as-is, including any potential whitespace, `v` prefix, etc.

func (Version) Public

func (v Version) Public() string

Public returns the public version

func (Version) String

func (v Version) String() string

String returns the full version string included pre-release and metadata information.

func (*Version) UnmarshalText

func (v *Version) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type WithPreRelease

type WithPreRelease bool

Jump to

Keyboard shortcuts

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