semver

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: MIT Imports: 3 Imported by: 3

README

Semver

Semver stuff I've used in a few projects such as Go Binaries.


GoDoc

Sponsors

This project is sponsored by my GitHub sponsors and by CTO.ai, making it easy for development teams to create and share workflow automations without leaving the command line.

Documentation

Overview

Package semver provides provides semver parsing and matching.

Index

Constants

This section is empty.

Variables

View Source
var ErrMalformed = errors.New("malformed version format, must be <major>.<minor>.<patch>")

ErrMalformed is returned when the format is incorrect.

View Source
var ErrMalformedRange = errors.New("malformed range format")

ErrMalformedRange is returned when the format is incorrect.

Functions

This section is empty.

Types

type Range

type Range struct {
	Major string
	Minor string
	Patch string
}

Range is a set of operations used to match a version, currently only wildcards are supported.

func ParseRange

func ParseRange(s string) (Range, error)

ParseRange returns a parsed range.

func (Range) Match

func (r Range) Match(v Version) bool

Match returns true if the range matches the version.

type Version

type Version struct {
	Major int
	Minor int
	Patch int
	Input string
}

Version is a set of versioned major, minor and patch levels.

func Parse

func Parse(s string) (Version, error)

Parse a semver string.

func (Version) Compare

func (v Version) Compare(other Version) int

Compare returns a comparison against version other:

-1 — v is less than other
0  — v is equal to other
1  — v is greather than other

func (Version) String

func (v Version) String() string

String implementation.

type Versions

type Versions []Version

Versions is a slice of versions.

func (Versions) Len

func (a Versions) Len() int

func (Versions) Less

func (a Versions) Less(i, j int) bool

func (Versions) Swap

func (a Versions) Swap(i, j int)

Jump to

Keyboard shortcuts

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