versions

package
v0.0.0-...-d3cc92b Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const FeedbackPkg = feedback.Package("versions")

Variables

View Source
var (
	ErrInvalidVersion      = errors.New("invalid version")
	ErrNoCompatibleVersion = errors.New("no compatible version")
)

Functions

func Compare

func Compare(a, b Version) int

Compare returns -1 if a is larger than b, 1 if b is larger than a and 0 if they are equal. x.y is treated as x.y.0

Types

type Version

type Version []int

func FindCompatibleInMap

func FindCompatibleInMap(version Version, versionsMap map[string]string) (Version, error)

FindCompatibleInMap returns the next best compatible module version in versionsMap (library/protocol version -> application version).

func MustParse

func MustParse(version string) Version

MustParse is like Parse but panics on error.

func Parse

func Parse(version string) (Version, error)

Parses the version string into the Version type.

func (Version) IsCompatible

func (v Version) IsCompatible(other Version) bool

IsCompatible returns false if one of the following conditions is true:

  • the major component differs
  • the major component is 0 AND the minor component differs
  • the minor component of `other` is greater than the minor component of `v`

func (Version) MarshalText

func (v Version) MarshalText() ([]byte, error)

func (Version) String

func (v Version) String() string

func (*Version) UnmarshalText

func (v *Version) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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