semver

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package semver implements comparison of semantic version strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(v, w fmt.Stringer) int

Compare returns an integer comparing two versions according to semantic version precedence. The result will be 0 if v == w, -1 if v < w, or +1 if v > w.

An invalid semantic version string is considered less than a valid one. All invalid semantic version strings compare equal to each other.

Types

type Tag

type Tag interface {
	Build() string
	Canonical() string
	IsTag() bool
	IsValid() bool
	Major() string
	MajorMinor() string
	Prerelease() string
	fmt.Stringer
}

Tag represents a version.

func Latest

func Latest(versions Tags) Tag

Latest returns the latest tag in the given list of versions.

func LatestMinor

func LatestMinor(major string, versions Tags) Tag

LatestMinor returns the latest minor version of the given major.

func LatestPatch

func LatestPatch(majorMinor string, versions Tags) Tag

LatestPatch returns the latest version with this major and minor.

type Tags

type Tags []Tag

Tags represents a list of versions that can be sorted.

func (Tags) Len

func (t Tags) Len() int

Len implements the sort interface.

func (Tags) Less

func (t Tags) Less(i, j int) bool

Less implements the sort interface.

func (Tags) Not

func (t Tags) Not(w fmt.Stringer) Tags

Not removes from the list of tags the given tag.

func (Tags) Swap

func (t Tags) Swap(i, j int)

Swap implements the sort interface.

type Version

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

Version represents a semantic version.

func New

func New(version string) *Version

New returns a new instance of PrintVersion.

func (Version) Build

func (v Version) Build() string

Build implements the Tag interface.

func (Version) Canonical

func (v Version) Canonical() string

Canonical implements the Tag interface.

func (Version) IsTag

func (v Version) IsTag() bool

IsTag implements the Tag interface.

func (Version) IsValid

func (v Version) IsValid() bool

IsValid implements the Tag interface.

func (Version) Major

func (v Version) Major() string

Major implements the Tag interface.

func (Version) MajorMinor

func (v Version) MajorMinor() string

MajorMinor implements the Tag interface.

func (Version) Prerelease

func (v Version) Prerelease() string

Prerelease implements the Tag interface.

func (Version) String

func (v Version) String() string

String implements the Tag interface.

Jump to

Keyboard shortcuts

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