Documentation ¶
Overview ¶
Package semver provides a Semantic Versioning library for Go. It allows you to parse and compare semver version strings. Covers version 2.0.0 of the semver specification.
Index ¶
- type Version
- func (v *Version) Compare(other *Version) int
- func (v *Version) DecrementMajor()
- func (v *Version) DecrementMinor()
- func (v *Version) DecrementPatch()
- func (v *Version) IncrementMajor()
- func (v *Version) IncrementMinor()
- func (v *Version) IncrementPatch()
- func (v Version) Major() uint64
- func (p *Version) MarshalJSON() ([]byte, error)
- func (v Version) Metadata() string
- func (v Version) Minor() uint64
- func (v Version) Patch() uint64
- func (v Version) Prerelease() string
- func (v Version) Satifies(requirements string) (bool, error)
- func (v *Version) SetMajor(major uint64)
- func (v *Version) SetMetadata(identifiers ...string) error
- func (v *Version) SetMinor(minor uint64)
- func (v *Version) SetPatch(patch uint64)
- func (v *Version) SetPrerelease(identifiers ...string) error
- func (v Version) String() string
- func (v *Version) UnmarshalJSON(b []byte) error
- type Versions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version is the container for semver version data.
func Build ¶
Build accepts version numbers in uint64 and optional prerelease and metadata information in a string array. Build circumvents error checking, and is mostly used for testing.
func New ¶
New accepts a valid semver version string and returns a Version struct. Returns error if the supplied string is an invalid semver version.
func (*Version) Compare ¶
Compare accepts a Version and compares itself against it, returning >0 for greater than, 0 for equals and <0 for less than.
func (*Version) DecrementMajor ¶
func (v *Version) DecrementMajor()
DecrementMajor decreases Major version by 1.
func (*Version) DecrementMinor ¶
func (v *Version) DecrementMinor()
DecrementMinor decreases Minor version by 1.
func (*Version) DecrementPatch ¶
func (v *Version) DecrementPatch()
DecrementPatch decreases Patch version by 1.
func (*Version) IncrementMajor ¶
func (v *Version) IncrementMajor()
IncrementMajor increases Major version by 1.
func (*Version) IncrementMinor ¶
func (v *Version) IncrementMinor()
IncrementMinor increases Minor version by 1.
func (*Version) IncrementPatch ¶
func (v *Version) IncrementPatch()
IncrementPatch increases Patch version by 1.
func (*Version) MarshalJSON ¶
func (Version) Prerelease ¶
Prerelease returns the prerelease identifiers as a dot seperated string.
func (Version) Satifies ¶
Satifies accepts a set of comparators and version numbers as a string. The syntax for the string is documented here: https://www.npmjs.org/doc/misc/semver.html Returns true if Version matches the comparators, false if it does not.
func (*Version) SetMetadata ¶
SetMetadata accepts a series of strings to form the metadata identifiers. Returns error if any of the supplied strings aren't a valid metadata identifier.
func (*Version) SetPrerelease ¶
SetPrerelease accepts a series of strings to form the prerelease identifiers. Returns error if any of the supplied strings aren't a valid prerelease identifier.
func (Version) String ¶
String returns a valid semver string based on the data contained in Version.