semver

package
v0.0.0-...-1e0f2b1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidVersion = errors.New("invalid semantic version format")

ErrInvalidVersion is the error returned when trying to parse a string that is not semantic versioning compliant.

Functions

This section is empty.

Types

type Version

type Version struct {
	Major string
	Minor string
	Patch string
	// contains filtered or unexported fields
}

Version is a structure that holds the representation of a concrete semantic version.

func MustParse

func MustParse(s string) Version

MustParse is the equivalent of ShouldParse but instead of returning an error it directly panics.

func Parse

func Parse(s string) (Version, bool)

Parse tries to parse the given string and returns a Version if the string is semantic versioning compliant. The boolean returned indicates whether the string is semantic versioning compliant.

func ShouldParse

func ShouldParse(s string) (Version, error)

ShouldParse is the equivalent of Parse but instead of returning a boolean that indicates whether the string is semantic versioning compliant, it returns an error.

func Zero

func Zero() Version

Zero is the zero value of Version, with all fields set to "0".

func (Version) Equals

func (v Version) Equals(to Version) bool

Equals returns true if the version is equal to the given version.

func (Version) GreaterThan

func (v Version) GreaterThan(to Version) bool

GreaterThan returns true if the version is greater than the given version.

func (Version) GreaterThanOrEquals

func (v Version) GreaterThanOrEquals(to Version) bool

GreaterThanOrEquals returns true if the version is greater than or equal to the given version.

func (Version) LowerThan

func (v Version) LowerThan(to Version) bool

LowerThan returns true if the version is lower than the given version.

func (Version) LowerThanOrEquals

func (v Version) LowerThanOrEquals(to Version) bool

LowerThanOrEquals returns true if the version is lower than or equal to the given version.

func (Version) NotEquals

func (v Version) NotEquals(to Version) bool

NotEquals returns true if the version is not equal to the given version.

func (Version) ShouldUpdate

func (v Version) ShouldUpdate(to Version) bool

ShouldUpdate returns true if the version should be updated to the given version.

func (Version) String

func (v Version) String() string

String returns the string representation of the version.

Jump to

Keyboard shortcuts

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