semver

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package semver provides functionality to parse and process semantic versions, as they are used in multiple components of Constellation.

The official semantic versioning specification disallows leading "v" prefixes. However, the Constellation config uses the "v" prefix for versions to make version strings more recognizable. This package bridges the gap between Go's semver pkg (doesn't allow "v" prefix) and the Constellation config (requires "v" prefix).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort added in v2.10.0

func Sort(list []Semver)

Sort sorts a list of semantic version strings using [ByVersion].

func ToStrings added in v2.10.0

func ToStrings(in []Semver) []string

ToStrings converts a slice of Semver to a slice of strings.

Types

type Semver

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

Semver represents a semantic version.

func New added in v2.7.0

func New(version string) (Semver, error)

New returns a Version from a string.

func NewFromInt added in v2.10.0

func NewFromInt(major, minor, patch int, prerelease string) Semver

NewFromInt constructs a new Semver from three integers and prerelease string: MAJOR.MINOR.PATCH-PRERELEASE.

func NewSlice added in v2.10.0

func NewSlice(in []string) ([]Semver, error)

NewSlice returns a slice of Semver from a slice of strings.

func (Semver) Compare

func (v Semver) Compare(other Semver) int

Compare compares two versions. It relies on the semver.Compare function internally. The result will be 0 if v == w, -1 if v < w, or +1 if v > w.

func (Semver) IsUpgradeTo

func (v Semver) IsUpgradeTo(other Semver) error

IsUpgradeTo returns if a version is an upgrade to another version. It checks if the version of v is greater than the version of other and allows a drift of at most one minor version.

func (Semver) Major

func (v Semver) Major() int

Major returns the major version of the object.

func (Semver) MajorMinorEqual added in v2.9.0

func (v Semver) MajorMinorEqual(other Semver) bool

MajorMinorEqual returns if the major and minor version of two versions are equal.

func (Semver) MarshalJSON

func (v Semver) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Semver) MarshalYAML added in v2.10.0

func (v Semver) MarshalYAML() (any, error)

MarshalYAML implements the yaml.Marshaller interface.

func (Semver) Minor

func (v Semver) Minor() int

Minor returns the minor version of the object.

func (Semver) NextMinor

func (v Semver) NextMinor() string

NextMinor returns the next minor version in the format "vMAJOR.MINOR+1".

func (Semver) Patch

func (v Semver) Patch() int

Patch returns the patch version of the object.

func (Semver) Prerelease added in v2.7.0

func (v Semver) Prerelease() string

Prerelease returns the prerelease section of the object.

func (Semver) String

func (v Semver) String() string

String returns the string representation of the version.

func (*Semver) UnmarshalJSON

func (v *Semver) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Semver) UnmarshalYAML added in v2.10.0

func (v *Semver) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

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