Documentation
¶
Index ¶
- Constants
- type Version
- func (v *Version) Compare(other *Version) int
- func (v *Version) Equal(o *Version) bool
- func (v *Version) GreaterThan(o *Version) bool
- func (v *Version) GreaterThanOrEqual(o *Version) bool
- func (v *Version) LessThan(o *Version) bool
- func (v *Version) LessThanOrEqual(o *Version) bool
- func (v *Version) Metadata() string
- func (v *Version) Original() string
- func (v *Version) Prerelease() string
- func (v *Version) Segments() []int
- func (v *Version) Segments64() []int64
- func (v *Version) String() string
Constants ¶
const ( VersionRegexpRaw string = `v?([0-9]+(\.[0-9]+)*?)` + `(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-?([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?` + `(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?` + `?` // SemverRegexpRaw requires a separator between version and prerelease SemverRegexpRaw string = `v?([0-9]+(\.[0-9]+)*?)` + `(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?` + `(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?` + `?` )
The raw regular expression string used for testing the validity of a version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version represents a single version.
func GetLatestVersion ¶
func GetRandomVersion ¶
func NewGoVersion ¶
func NewVersion ¶
NewVersion parses the given version and returns a new Version.
func (*Version) Compare ¶
Compare compares this version to another version. This returns -1, 0, or 1 if this version is smaller, equal, or larger than the other version, respectively.
If you want boolean results, use the LessThan, Equal, GreaterThan, GreaterThanOrEqual or LessThanOrEqual methods.
func (*Version) GreaterThan ¶
GreaterThan tests if this version is greater than another version.
func (*Version) GreaterThanOrEqual ¶
GreaterThanOrEqual tests if this version is greater than or equal to another version.
func (*Version) LessThanOrEqual ¶
LessThanOrEqual tests if this version is less than or equal to another version.
func (*Version) Metadata ¶
Metadata returns any metadata that was part of the version string.
Metadata is anything that comes after the "+" in the version. For example, with "1.2.3+beta", the metadata is "beta".
func (*Version) Prerelease ¶
Prerelease returns any prerelease data that is part of the version, or blank if there is no prerelease data.
Prerelease information is anything that comes after the "-" in the version (but before any metadata). For example, with "1.2.3-beta", the prerelease information is "beta".
func (*Version) Segments ¶
Segments returns the numeric segments of the version as a slice of ints.
This excludes any metadata or pre-release information. For example, for a version "1.2.3-beta", segments will return a slice of 1, 2, 3.
func (*Version) Segments64 ¶
Segments64 returns the numeric segments of the version as a slice of int64s.
This excludes any metadata or pre-release information. For example, for a version "1.2.3-beta", segments will return a slice of 1, 2, 3.
func (*Version) String ¶
String returns the full version string included pre-release and metadata information.
This value is rebuilt according to the parsed segments and other information. Therefore, ambiguities in the version string such as prefixed zeroes (1.04.0 => 1.4.0), `v` prefix (v1.0.0 => 1.0.0), and missing parts (1.0 => 1.0.0) will be made into a canonicalized form as shown in the parenthesized examples.