version

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Version

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

Version represents a semantic version; see https://semver.org/spec/v2.0.0.html.

func MustParse

func MustParse(str string) *Version

MustParse is like Parse but panics on any error. Recommended as an initializer for global values.

func Parse

func Parse(str string) (*Version, error)

Parse creates a version from a string. The string must be a valid semantic version (as per https://semver.org/spec/v2.0.0.html) in the format:

"vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".

MINOR, MAJOR, and PATCH are numeric values (without any leading 0s). PRERELEASE and METADATA can contain ASCII characters and digits, hyphens and dots.

func (*Version) AtLeast

func (v *Version) AtLeast(w *Version) bool

AtLeast returns true if v >= w.

func (*Version) Compare

func (v *Version) Compare(w *Version) int

Compare returns -1, 0, or +1 indicating the relative ordering of versions.

func (*Version) Major

func (v *Version) Major() int

Major returns the major (first) version number.

func (*Version) Metadata

func (v *Version) Metadata() string

Metadata returns the metadata (if present).

func (*Version) Minor

func (v *Version) Minor() int

Minor returns the minor (second) version number.

func (*Version) Patch

func (v *Version) Patch() int

Patch returns the patch (third) version number.

func (*Version) PreRelease

func (v *Version) PreRelease() string

PreRelease returns the pre-release version (if present).

func (Version) String

func (v Version) String() string

String returns the string representation, in the format:

"v1.2.3-beta+md"

Jump to

Keyboard shortcuts

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