version

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Copyright (C) 2023 by Posit Software, PBC

Copyright (C) 2023 by Posit Software, PBC

Index

Constants

This section is empty.

Variables

View Source
var ManifestVersionSeparators = []rune{'/', '.'}

ManifestVersionSeparators are valid separators for versions. For example, these are all valid versions:

`1.2.3.4`
`1-2-3`
`1-2.3-4.5`

Functions

func CompareManifestVersions

func CompareManifestVersions(a, b ManifestVersion) int

CompareManifestVersions compares the numerical components of two versions.

returns:

-1 if a < b
 0 if a == b
 1 if a > b

func CompareSchemaMajor

func CompareSchemaMajor(a, b ManifestVersion) int

CompareSchemaMajor compares schema, major (NOT minor) of two versions.

returns:

-1 iff a < b
 0 iff a == b
 1 iff a > b

The schema and major version are sorted numerically.

func CompareVersions

func CompareVersions(a, b RVersion) int

CompareVersions compares the numerical components of two versions.

returns:

-1 if a < b
 0 if a == b
 1 if a > b

Types

type ManifestVersion

type ManifestVersion struct {
	Raw    string
	Schema int
	Major  int
	Minor  int
	Parts  []int
	Set    bool
}

ManifestVersion represents semantic version information with each component as an int. Other types of version strings are not supported.

func NewManifestVersion

func NewManifestVersion(schema, major, minor int) ManifestVersion

func ParseNewManifestVersion

func ParseNewManifestVersion(s string) (ManifestVersion, error)

ParseNewManifestVersion creates a ManifestVersion from a string.

func (ManifestVersion) Equals

func (v ManifestVersion) Equals(other ManifestVersion) bool

Equals tests that this version is equivalent to another.

func (ManifestVersion) EqualsMajor

func (v ManifestVersion) EqualsMajor(other ManifestVersion) bool

EqualsMajor tests that this version is equivalent to another in major version.

func (ManifestVersion) GreaterThan

func (v ManifestVersion) GreaterThan(other ManifestVersion) bool

GreaterThan tests that this version is greater than another.

func (ManifestVersion) LessThan

func (v ManifestVersion) LessThan(other ManifestVersion) bool

LessThan tests that this version is greater than another.

func (ManifestVersion) LessThanMajor

func (v ManifestVersion) LessThanMajor(other ManifestVersion) bool

LessThanMajor tests that this version is greater in schema/major version than another

func (ManifestVersion) LessThanOrEqual

func (v ManifestVersion) LessThanOrEqual(other ManifestVersion) bool

LessThanOrEqual tests that this version is less than or equal to another.

func (ManifestVersion) MarshalJSON

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

MarshalJSON satisfies the JSON marshalling interface.

func (*ManifestVersion) Parse

func (v *ManifestVersion) Parse() error

Parse version information from a string. Supports the following formats:

- W.X - W.X.Y - W.X.Y.Z - W.X.Y-Z (last components may be separated by a hyphens)

Each component must be integral.

func (ManifestVersion) String

func (v ManifestVersion) String() string

String generates a string representation of the version.

func (*ManifestVersion) UnmarshalJSON

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

UnmarshalJSON satisfies the JSON unmarshalling interface.

type RVersion

type RVersion struct {
	Raw   string
	Major int
	Minor int
	Patch int
	Rev   int
	Parts []int
	Set   bool
	Err   error
}

RVersion represents semantic version information with each component as an int. Other types of version strings are not supported.

func ParseNewVersion

func ParseNewVersion(s string) (RVersion, error)

ParseNewVersion creates a RVersion from a string.

func (RVersion) Equals

func (v RVersion) Equals(other RVersion) bool

Equals tests that this version is equivalent to another.

func (RVersion) GreaterThan

func (v RVersion) GreaterThan(other RVersion) bool

GreaterThan tests that this version is greater than another.

func (RVersion) LessThan

func (v RVersion) LessThan(other RVersion) bool

LessThan tests that this version is greater than another.

func (RVersion) MarshalJSON

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

MarshalJSON satisfies the JSON marshalling interface.

func (*RVersion) Parse

func (v *RVersion) Parse() error

Parse version information from a string. Supports the following formats:

- W.X - W.X.Y - W.X.Y.Z - W.X.Y-Z (last components may be separated by a hyphens)

Each component must be integral.

func (RVersion) String

func (v RVersion) String() string

String generates a string representation of the version.

func (*RVersion) UnmarshalJSON

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

UnmarshalJSON satisfies the JSON unmarshalling interface.

Jump to

Keyboard shortcuts

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