Documentation
¶
Overview ¶
Package semver implements the Semantic Versioning standard. It provides utilities for parsing, comparing, and incrementing version numbers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSemver = errors.New("invalid semantic version specifier")
ErrSemver indicates a malformed version string.
Functions ¶
This section is empty.
Types ¶
type Semver ¶
type Semver struct {
Major uint
Minor uint
Patch uint
// One or more prerelease identifiers. Nil if this is a normal release.
Prerelease []string
// One or more build metadata identifiers. Nil if not provided.
// Most operations, including comparison, will ignore this field.
Build []string
}
func Parse ¶
Parse converts a string to a Semver object. If the string is not a valid version specifier, it returns ErrSemver.
func (*Semver) Compare ¶
Compare checks if two version specifiers are different. It returns:
- -1 if the first version specifier has lower precedence
- 0 if the version specifiers are equal
- 1 if the first version specifier has higher precedence
Build metadata is ignored.
func (*Semver) IsStable ¶
IsStable returns true if the version is not a prerelease, and the major version number is not 0. (Major version 0 is used for initial development).
func (*Semver) NextMajor ¶
NextMajor returns a new Semver object representing the next major version in the sequence.
func (*Semver) NextMinor ¶
NextMinor returns a new Semver object representing the next minor version in the sequence.
func (*Semver) NextPatch ¶
NextPatch returns a new Semver object representing the next patch version in the sequence.
func (*Semver) NextRelease ¶
NextRelease returns a new Semver object with prerelease and build information stripped. (It is used to determine the next stable release on a prerelease branch.)