semvery

package
v1.0.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package semvery parses version strings that are conventionally SemVer but allow an omitted v prefix, omitted numeric components, or leading zeroes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b Version) int

Compare compares two parsed versions according to SemVer precedence.

Types

type Version

type Version struct {
	// Canonical is the strict, normalized SemVer representation used for
	// comparison, such as "v1.2.0" for the source spelling "01.2".
	Canonical string

	// HasVPrefix reports whether the source spelling started with "v".
	HasVPrefix bool

	// RawParts contains the numeric components exactly as written, before
	// removing leading zeroes or appending omitted components.
	RawParts []string

	// Prerelease includes the leading "-", or is empty when none was given.
	Prerelease string

	// Build includes the leading "+", or is empty when none was given.
	Build string
}

Version is a parsed SemVer-like version. It contains both the strict SemVer representation used for precedence and details about the source spelling used to choose between equivalent tags.

func Parse

func Parse(version string) (Version, bool)

Parse parses a SemVer-like version and returns its strict SemVer representation. It accepts one to three numeric components, leading zeroes, and an optional v prefix.

Jump to

Keyboard shortcuts

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