Documentation
¶
Overview ¶
Package semver provides functions for parsing, validating, and bumping semantic version numbers according to the Semantic Versioning 2.0.0 specification. See https://semver.org/ for the full specification.
This package handles versions with or without a leading 'v' prefix and provides options to preserve or remove the prefix when formatting.
Index ¶
- Variables
- func BumpMajor(version string, useVPrefix bool) (string, error)
- func BumpMinor(version string, useVPrefix bool) (string, error)
- func BumpPatch(version string, useVPrefix bool) (string, error)
- func BumpVersion(version string, bumpType BumpType, useVPrefix bool) (string, error)
- func Compare(v1, v2 string) (int, error)
- func FormatVersion(ver semver.Version, includePrefix bool) string
- func ParseVersion(version string) (semver.Version, bool, error)
- type BumpType
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidVersion = errors.New("invalid version format") ErrInvalidBump = errors.New("invalid bump type") )
Common errors returned by semver operations
Functions ¶
func BumpMajor ¶
BumpMajor increments the major version number This resets the minor and patch numbers to 0 useVPrefix determines whether to add 'v' prefix to the output
func BumpMinor ¶
BumpMinor increments the minor version number This resets the patch number to 0 useVPrefix determines whether to add 'v' prefix to the output
func BumpPatch ¶
BumpPatch increments the patch version number useVPrefix determines whether to add 'v' prefix to the output
func BumpVersion ¶ added in v1.0.0
BumpVersion increments a version number based on the bump type Returns the new version string and an error if the version is invalid useVPrefix determines whether to add 'v' prefix to the output (true = add 'v', false = no prefix)
func Compare ¶
Compare compares two version strings and returns:
-1 if v1 < v2 0 if v1 == v2 +1 if v1 > v2
func FormatVersion ¶ added in v1.0.0
FormatVersion formats a semver.Version object as a string If includePrefix is true, the string will be prefixed with 'v'