Documentation
¶
Overview ¶
Package semver provides a set of utilities for working with semantic versions in Go.
Index ¶
- Constants
- func CompareRaw(ver1, ver2 string) (int, error)
- type SemVer
- func (s *SemVer) Compare(v *SemVer) (int, error)
- func (s *SemVer) CurrentBuild() string
- func (s *SemVer) CurrentMajor() int
- func (s *SemVer) CurrentMinor() int
- func (s *SemVer) CurrentPatch() int
- func (s *SemVer) CurrentPreRelease() string
- func (s *SemVer) IsCurrentPreRelease() bool
- func (s *SemVer) NextMajor() *SemVer
- func (s *SemVer) NextMinor() *SemVer
- func (s *SemVer) NextPatch() *SemVer
- func (s *SemVer) NextPreRelease(tag string) *SemVer
- func (s *SemVer) String() string
Constants ¶
const ( RegexSemver = `^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$` RegexPreRelease = `^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)` )
Variables ¶
This section is empty.
Functions ¶
func CompareRaw ¶
CompareRaw returns three values -1, 0, +1 -1 denotes ver1 < ver2 0 denotes invalid input +1 denotes ver1 > ver2
Types ¶
type SemVer ¶
type SemVer struct {
// contains filtered or unexported fields
}
SemVer is a struct that represents a semantic version with major, minor, patch, pre-release and build metadata. For more information on semantic versioning, see https://semver.org/spec/v2.0.0.html
func Parse ¶
Parse will parse the given input string and provide a semver struct If the input string is not a valid semver string, an error will be returned
func (*SemVer) Compare ¶
Compare returns three values -1, 0, +1 -1 denotes ver1 < ver2 0 denotes invalid input +1 denotes ver1 > ver2
func (*SemVer) CurrentBuild ¶ added in v1.0.7
Build returns the build metadata of the SemVer struct.
func (*SemVer) CurrentMajor ¶ added in v1.0.7
Major returns the major version of the SemVer struct.
func (*SemVer) CurrentMinor ¶ added in v1.0.7
Minor returns the minor version of the SemVer struct.
func (*SemVer) CurrentPatch ¶ added in v1.0.7
Patch returns the patch version of the SemVer struct.
func (*SemVer) CurrentPreRelease ¶ added in v1.0.7
PreRelease returns the pre-release metadata of the SemVer struct.
func (*SemVer) IsCurrentPreRelease ¶ added in v1.0.7
func (*SemVer) NextPreRelease ¶ added in v1.0.7
NextPreRelease