semver

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package semver is a small, dependency-free Semantic Versioning 2.0.0 parser and comparator, sufficient for Rune's `minimum_version` requirement gate. It deliberately implements only what the gate needs — parse, precedence compare, and a `>=` satisfaction test — rather than a full constraint language.

Precedence follows SemVer 2.0.0: the numeric core is compared first, a prerelease ranks below the otherwise-equal release (so 0.9.0-rc.1 < 0.9.0), prerelease identifiers are compared field-by-field (numeric identifiers rank below alphanumeric ones), and build metadata is ignored entirely.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Version

type Version struct {
	Major, Minor, Patch int
	Prerelease          []string // dot-separated identifiers; empty for a release
	Build               []string // build metadata; ignored for precedence
}

Version is a parsed semantic version. Build metadata is retained for round-tripping but never affects precedence.

func Parse

func Parse(s string) (Version, error)

Parse parses a semantic version of the form MAJOR.MINOR.PATCH[-pre][+build]. A leading "v", a partial core (e.g. "0.8"), leading zeros in numeric fields, and empty identifiers are rejected.

func (Version) Compare

func (v Version) Compare(o Version) int

Compare returns -1, 0, or +1 as v is less than, equal to, or greater than o in SemVer precedence. Build metadata is ignored.

func (Version) Satisfies

func (v Version) Satisfies(min Version) bool

Satisfies reports whether v meets the minimum requirement min (v >= min).

func (Version) String

func (v Version) String() string

String renders the version in canonical form.

Jump to

Keyboard shortcuts

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