version

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterByMultiple

func FilterByMultiple(versions []string, specifiers []*Specifier) ([]string, error)

FilterByMultiple filters versions by multiple specifiers (all must match)

func SelectBest

func SelectBest(versions []string) (string, error)

SelectBest selects the best (highest) version from a list

Types

type Specifier

type Specifier struct {
	Operator string
	Version  *Version
}

Specifier represents a version specifier (e.g., ">=1.2.3")

func ParseMultipleSpecifiers

func ParseMultipleSpecifiers(spec string) ([]*Specifier, error)

ParseMultipleSpecifiers parses comma-separated specifiers (e.g., ">=1.0,<2.0")

func ParseSpecifier

func ParseSpecifier(spec string) (*Specifier, error)

ParseSpecifier parses a version specifier

func (*Specifier) Filter

func (s *Specifier) Filter(versions []string) ([]string, error)

Filter filters a list of version strings by the specifier

func (*Specifier) Matches

func (s *Specifier) Matches(v *Version) bool

Matches checks if a version matches the specifier

type Version

type Version struct {
	Major int
	Minor int
	Patch int
	Pre   string // Pre-release suffix (e.g., "alpha", "beta")
	Build string // Build metadata (e.g., "+20250120")
}

Version represents a semantic version

func Parse

func Parse(v string) (*Version, error)

Parse parses a semantic version string

func (*Version) Compare

func (v *Version) Compare(other *Version) int

Compare compares two versions Returns -1 if v < other, 0 if v == other, 1 if v > other

func (*Version) String

func (v *Version) String() string

String returns the string representation of the version

Jump to

Keyboard shortcuts

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