semver

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

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

View Source
const BuildMetadataGroup = "buildmetadata"

BuildMetadataGroup is the string name of the capture group for the SemVer build metadata version

View Source
const MajorGroup = "major"

MajorGroup is the string name of the capture group for the SemVer major version

View Source
const MinorGroup = "minor"

MinorGroup is the string name of the capture group for the SemVer minor version

View Source
const PatchGroup = "patch"

PatchGroup is the string name of the capture group for the SemVer patch version

View Source
const Pattern string = `` /* 237-byte string literal not displayed */

Pattern is a string representation of the regular expression to capture SemVers

View Source
const PreReleaseGroup = "prerelease"

PreReleaseGroup is the string name of the capture group for the SemVer prerelease version

View Source
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

View Source
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

func BuildMetadata(input string) (string, error)

BuildMetadata returns the BuildMetadata (x.y.z-prereleaseBuildMetadata) version of a string SemVer

func GetCaptureGroupMatch

func GetCaptureGroupMatch(re *regexp.Regexp, name, input string) (string, error)

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 Major

func Major(input string) (string, error)

Major returns the Major (X.y.z) version of a string SemVer

func MapNamedCaptureGroups

func MapNamedCaptureGroups(re *regexp.Regexp, input string) map[string]string

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 Minor

func Minor(input string) (string, error)

Minor returns the Minor (x.Y.z) version of a string SemVer

func Patch

func Patch(input string) (string, error)

Patch returns the Patch (x.y.Z) version of a string SemVer

func PreRelease

func PreRelease(input string) (string, error)

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 Make

func Make(input string) (SemVer, error)

Make returns a SemVer object from 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.

func (*SemVer) BumpPatch

func (v *SemVer) BumpPatch()

BumpPatch increments the patch version by 1. It also clears the prerelease and buildmetadata versions.

func (SemVer) String

func (v SemVer) String() string

func (SemVer) VString

func (v SemVer) VString() string

VString returns a string representation of the SemVer with a leading "v".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL