version

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 3 Imported by: 8

Documentation

Overview

Package version describes a version used for a repository.

The version for an entity is composed of a major version, minor version, and patch. The major and minor version numbers are both integers and dictate the compatibility between two versions. The patch provides extra information that is not part of the compatibility check, but still must be present.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmp

func Cmp(a, b Version) int

Cmp compares two Versions. Return 1 if a is greater than b, -1 if a is less than b, and 0 if they are equal. A Version

func Equal

func Equal(a, b Version) bool

Equal determines if two Version objects are equal. They are equal when major, minor, and patch are all the same

func IsCompatible

func IsCompatible(required, current Version) bool

IsCompatible determines if the current Version is compatible with the required Version. Version are compatible when the major versions are equal and the current minor version is greater than or equal to the required version. The patches do not need to match.

Types

type Version

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

Version structure contains the major, minor, and patch information.

func New

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

New returns a new Version with the given major, minor and patch.

func ParseVersion

func ParseVersion(versionString string) (Version, error)

ParseVersion parses a string into a Version object. An error is returned for invalid version string. To be valid, a string must contain a major integer, a minor integer, and a patch string separated by a period.

func (Version) Major

func (v Version) Major() int

Major returns the major integer of the Version.

func (Version) Minor

func (v Version) Minor() int

Minor returns the minor integer of the Version.

func (Version) Patch

func (v Version) Patch() string

Patch returns the patch string of the Version.

func (Version) String

func (v Version) String() string

String prints the Version in a string format of the form "major.minor.path".

Jump to

Keyboard shortcuts

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