semantic

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0, BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package semantic provides version parsing and comparison for various ecosystems, matching the native versioning rules of each ecosystem.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidVersion = errors.New("invalid version")

ErrInvalidVersion is returned for malformed version strings.

View Source
var ErrUnsupportedEcosystem = errors.New("unsupported ecosystem")

ErrUnsupportedEcosystem is returned for unsupported ecosystems.

Functions

This section is empty.

Types

type Version

type Version interface {
	// CompareStr returns an integer representing the sort order of the given string
	// when parsed as the concrete Version relative to the subject Version.
	//
	// The result will be 0 if v == w, -1 if v < w, or +1 if v > w.
	//
	// An error is returned if the given string is not a valid Version, with "valid"
	// being dependent on the underlying ecosystem of the concrete Version.
	CompareStr(str string) (int, error)
}

Version provides an interface for sortable version strings.

func MustParse

func MustParse(str string, ecosystem string) Version

MustParse is like Parse but panics if the ecosystem is not supported.

func Parse

func Parse(str string, ecosystem string) (Version, error)

Parse attempts to parse the given string as a version for the specified ecosystem, returning an ErrUnsupportedEcosystem error if the ecosystem is not supported.

Jump to

Keyboard shortcuts

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