version

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

Package version helps other packages to provide information about their current version and compare it to others. It follows the idea of semantic versioning (see http://semver.org/).

Version instances can be created via New() with explicit passed field values or via Parse() and a passed sting. Beside accessing the individual fields two versions can be compared with Compare() and Less().

Index

Constants

View Source
const (
	Metadata = "+"

	Newer Precedence = 1
	Equal Precedence = 0
	Older Precedence = -1

	Major      Level = "major"
	Minor      Level = "minor"
	Patch      Level = "patch"
	PreRelease Level = "pre-release"
	All        Level = "all"
)

Separator, precedences, and part identifiers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level string

Level describes the level, on which a version differentiates from an other.

type Precedence

type Precedence int

Precedence describes if a version is newer, equal, or older.

type Version

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

Version implements the version interface.

func New

func New(major, minor, patch int, prmds ...string) Version

New returns a simple version instance. Parts of pre-release and metadata are passed as optional strings separated by version.Metadata ("+").

func Parse

func Parse(vsnstr string) (Version, error)

Parse retrieves a version out of a string.

func (Version) Compare

func (v Version) Compare(cv Version) (Precedence, Level)

Compare compares this version to the passed one. The result is from the perspective of this one.

func (Version) Less

func (v Version) Less(cv Version) bool

Less returns true if this version is less than the passed one. This means this version is older.

func (Version) Major

func (v Version) Major() int

Major returns the major version.

func (Version) Metadata

func (v Version) Metadata() string

Metadata returns a possible build metadata of the version.

func (Version) Minor

func (v Version) Minor() int

Minor returns the minor version.

func (Version) Patch

func (v Version) Patch() int

Patch return the patch version.

func (Version) PreRelease

func (v Version) PreRelease() string

PreRelease returns a possible pre-release of the version.

func (Version) String

func (v Version) String() string

String implements the fmt.Stringer interface.

Jump to

Keyboard shortcuts

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