semver

package
v0.0.0-...-5622c37 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: EUPL-1.2 Imports: 6 Imported by: 0

Documentation

Overview

Package semver implements creation, comparison, and more of semantic version data.

The general form of a semantic version string is:

MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]

where square brackets indicate optional parts. MAJOR, MINMOR, and PATCH are decimal numbers without leading zeroes; PRERELEASE and BUILD are each one or more sequences of alphanumeric characters, separated by dots. PRERELEASE must not have leading zeroes.

This package follows Semantic Versioning 2.0.0 (see semver.org).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SemVer

type SemVer struct {
	Major      uint64
	Minor      uint64
	Patch      uint64
	PreRelease string
	Build      string
}

SemVer stores the parsed data for a semantic version string.

func MustParse

func MustParse(s string) SemVer

MustParse parses the string as a semantic version and panics if this is not possible.

func Parse

func Parse(s string) (SemVer, bool)

Parse a string as a semantic version string.

func (SemVer) Compare

func (v SemVer) Compare(o SemVer) int

Compare two semantic versions.

func (SemVer) Compatible

func (v SemVer) Compatible(n SemVer) bool

Compatible returns true, if the given new version is compatible to the first.

func (*SemVer) IncMajor

func (v *SemVer) IncMajor()

IncMajor increments the major version.

func (*SemVer) IncMinor

func (v *SemVer) IncMinor()

IncMinor increments the minor version.

func (*SemVer) IncPatch

func (v *SemVer) IncPatch()

IncPatch increments the patch version.

func (SemVer) String

func (v SemVer) String() string

String returns a string representation of the semantic version.

Source Files

  • semver.go

Jump to

Keyboard shortcuts

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