Documentation
¶
Overview ¶
Package semver provides a struct object representation of a semantic version, as well as several functions for working with both SemVer structs and semantic version strings.
Index ¶
- Constants
- Variables
- func BuildMetadata(input string) (string, error)
- func GetCaptureGroupMatch(re *regexp.Regexp, name, input string) (string, error)
- func Major(input string) (string, error)
- func MapNamedCaptureGroups(re *regexp.Regexp, input string) map[string]string
- func Minor(input string) (string, error)
- func Patch(input string) (string, error)
- func PreRelease(input string) (string, error)
- type SemVer
Constants ¶
const BuildMetadataGroup = "buildmetadata"
BuildMetadataGroup is the string name of the capture group for the SemVer build metadata version
const MajorGroup = "major"
MajorGroup is the string name of the capture group for the SemVer major version
const MinorGroup = "minor"
MinorGroup is the string name of the capture group for the SemVer minor version
const PatchGroup = "patch"
PatchGroup is the string name of the capture group for the SemVer patch version
const Pattern string = `` /* 237-byte string literal not displayed */
Pattern is a string representation of the regular expression to capture SemVers
const PreReleaseGroup = "prerelease"
PreReleaseGroup is the string name of the capture group for the SemVer prerelease version
const VPattern string = `` /* 242-byte string literal not displayed */
VPattern is a string representation of the regular expressions to capture SemVers with a leading "v"
Variables ¶
var ( // Regexp is a pointer to a compiled Regexp semver expression Regexp = regexp.MustCompile(Pattern) // VRegexp is a pointer to a compiled Regexp semver expression that accounts for an optional leading "v" VRegexp = regexp.MustCompile(VPattern) )
Functions ¶
func BuildMetadata ¶
BuildMetadata returns the BuildMetadata (x.y.z-prereleaseBuildMetadata) version of a string SemVer
func GetCaptureGroupMatch ¶
GetCaptureGroupMatch returns the match in string input of a single named capture group. A regexp.Regexp pointer to use for the matching is the first argument.
func MapNamedCaptureGroups ¶
MapNamedCaptureGroups returns a map of named regex capture groups where map[<group name>] = match Param re: A compiled regular expression Param input: A string to evaluate with the regular expression
func PreRelease ¶
PreRelease returns the PreRelease (x.y.z-PreRelease) version of a string SemVer
Types ¶
type SemVer ¶
type SemVer struct {
Major int
Minor int
Patch int
PreRelease string
BuildMetadata string
ParsedAsV bool
}
SemVer is a struct representation of a Semantic Version string
func (*SemVer) BumpMajor ¶
func (v *SemVer) BumpMajor()
BumpMajor increments the major version by 1. It also sets the minor and patch versions to 0 and clears the prelease and buildmetadata versions
func (*SemVer) BumpMinor ¶
func (v *SemVer) BumpMinor()
BumpMinor increments the minor version by 1. It also sets the patch version to 0 and clears the prerelease and buildmetadata versions.