versioning

package
v0.0.0-...-2b31b08 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string, compareMetadata func(aMeta, bMeta string) int) (int, error)

Compare compares 'a' and 'b'. The result will be 0 if a==b, -1 if a < b, and +1 if a > b. If compareMetadata==nil, will not compare metadata.

Types

type SemVer

type SemVer struct {
	// contains filtered or unexported fields
}

SemVer semantic version object via https://semver.org/

func Create

func Create(major, minor, patch uint32, metadata string) *SemVer

Create creates a semantic version object.

func Parse

func Parse(semVer string) (*SemVer, error)

Parse parses the semantic version string to object. NOTE: If metadata part exists, the separator must not be a number.

func (*SemVer) Compare

func (s *SemVer) Compare(semVer *SemVer, compareMetadata func(sMeta, semVerMeta string) int) int

Compare compares whether 's' and 'semVer'. The result will be 0 if s==semVer, -1 if s < semVer, and +1 if s > semVer. If compareMetadata==nil, will not compare metadata.

func (*SemVer) Major

func (s *SemVer) Major() string

Major returns the version major.

func (*SemVer) Metadata

func (s *SemVer) Metadata() string

Metadata returns the version metadata. Examples:

1.0.0-alpha+001 => -alpha+001
1.0.0+20130313144700 => +20130313144700
1.0.0-beta+exp.sha.5114f85 => -beta+exp.sha.5114f85
1.0.0rc => rc

func (*SemVer) Minor

func (s *SemVer) Minor() string

Minor returns the version minor.

func (*SemVer) Patch

func (s *SemVer) Patch() string

Patch returns the version patch.

func (*SemVer) String

func (s *SemVer) String() string

String returns the version string.

Jump to

Keyboard shortcuts

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