semver

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package semver reads a version of a module, X.Y.Z, and orders two of them by Semantic Versioning 2.0.0, as the format writes a version: three decimal numerals with no leading zero, and no pre-release and no build metadata (format/README.md, sections 26 and 27; R46 spec). Package moduleindex orders the versions of a module by it, for the rule module-index.version-above and the version of a new attempt, and package module the format versions, MAJOR.MINOR, as the versions MAJOR.MINOR.0; package moduleversion orders the published versions of a module by it and raises a version to the next by one of its parts, Raise (R35, R36).

A numeral has no bound, as a version has none, so a Version keeps its numerals as text and orders them by their length first: no version is too large to read or to order.

Index

Constants

View Source
const (
	Major = iota
	Minor
	Patch
)

The places of the numbers of a version, from the highest, as Raise and Zero take them.

Variables

This section is empty.

Functions

This section is empty.

Types

type Version

type Version struct {
	// contains filtered or unexported fields
}

A Version is a version of a module, X.Y.Z: its major, minor and patch numbers, each a decimal numeral with no leading zero. Its zero value is no version.

func Parse

func Parse(s string) (Version, error)

Parse reads a version of a module, X.Y.Z, in the form of common.schema.json#/$defs/module_version: three decimal numerals with no leading zero, joined by ".", and nothing else.

func (Version) Compare

func (v Version) Compare(w Version) int

Compare gives -1, 0 or +1 as v stands below, at or above w by Semantic Versioning, section 11: by the major number, then the minor, then the patch, each by its value and not its text, so that 1.10.0 stands above 1.9.0.

func (Version) Raise added in v0.1.23

func (v Version) Raise(place int) Version

Raise gives the version with the number at place raised by one and every lower number 0, as a step to the next version by that part does (format/README.md, section 27): 1.2.3 raised at Minor is 1.3.0. The number has no bound: 9 is raised to 10 in its text, digit by digit.

func (Version) String

func (v Version) String() string

String writes the version as X.Y.Z.

func (Version) Zero added in v0.1.23

func (v Version) Zero(place int) bool

Zero says whether the number at place is 0.

Jump to

Keyboard shortcuts

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