Documentation
¶
Overview ¶
Package semver provides semantic version parsing and comparison for multiple package ecosystems. Supports: PyPI (PEP 440), npm (semver), cargo (Rust), and more.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize attempts to normalize a version string for the given system Returns the original string if parsing fails
func NormalizeNPMVersion ¶
NormalizeNPMVersion normalizes npm version strings Handles common npm version patterns like workspace:, file:, git:, etc. Following deps.dev patterns: preserve full strings for git/github/http URLs
Types ¶
type MavenVersion ¶
type MavenVersion struct {
// contains filtered or unexported fields
}
MavenVersion represents a Maven version with canonicalization support Format: [versionRange]major.minor.patch[-qualifier]
func (*MavenVersion) Canon ¶
func (v *MavenVersion) Canon(includeEpoch bool) string
Canon returns the canonical string representation of the Maven version
func (*MavenVersion) Compare ¶
func (v *MavenVersion) Compare(other Version) int
Compare compares this version with another version For Maven, this is a simplified comparison focusing on the canonical form
func (*MavenVersion) String ¶
func (v *MavenVersion) String() string
String returns the original version string
type NPMVersion ¶
type NPMVersion struct {
// contains filtered or unexported fields
}
NPMVersion represents an npm semver version Format: [v]major.minor.patch[-prerelease][+build]
func (*NPMVersion) Canon ¶
func (v *NPMVersion) Canon(includeEpoch bool) string
Canon returns the canonical string representation of the version
func (*NPMVersion) Compare ¶
func (v *NPMVersion) Compare(other Version) int
Compare compares this version with another version Following semver 2.0.0 precedence rules
func (*NPMVersion) String ¶
func (v *NPMVersion) String() string
String returns the original version string
type ParseError ¶
ParseError represents a version parsing error
func (ParseError) Error ¶
func (e ParseError) Error() string
type PyPIVersion ¶
type PyPIVersion struct {
// contains filtered or unexported fields
}
PyPIVersion represents a PEP 440 compliant version Based on: https://www.python.org/dev/peps/pep-0440/
func (*PyPIVersion) Canon ¶
func (v *PyPIVersion) Canon(includeEpoch bool) string
Canon returns the canonical string representation of the version
func (*PyPIVersion) Compare ¶
func (v *PyPIVersion) Compare(other Version) int
Compare compares this version with another version
func (*PyPIVersion) String ¶
func (v *PyPIVersion) String() string
String returns the original version string
type System ¶
type System interface {
// Parse parses a version string according to the system's rules
Parse(version string) (Version, error)
// Name returns the name of the versioning system
Name() string
}
System represents a versioning system (PyPI, npm, cargo, etc.)
type Version ¶
type Version interface {
// Canon returns the canonical string representation of the version
Canon(includeEpoch bool) string
// Compare compares this version with another version
// Returns: -1 if this < other, 0 if this == other, 1 if this > other
Compare(other Version) int
// String returns the original version string
String() string
}
Version represents a parsed semantic version