Documentation ¶
Index ¶
- Constants
- func CastVersion(name, val string) (int, error)
- func Latest(doc string) (string, error)
- func LatestAny(doc string) (string, error)
- func Show(doc string, ver string) ([]string, error)
- func To(doc string, ver string) (string, error)
- func Version(in string) (string, error)
- type SemanticVersion
- type VersionType
Constants ¶
const ( // Unreleased tag is defined in keepachangelog 1.0.0. // https://keepachangelog.com/en/1.0.0/ Unreleased = "[Unreleased]" )
Variables ¶
This section is empty.
Functions ¶
func CastVersion ¶
CastVersion parse and set a string into given struct.
func Latest ¶
Latest returns the latest version stored in document. This operation simply matches to the first h2 header.
func LatestAny ¶
LatestAny returns the latest [version] stored in document. Unlike `Latest` which follows Semantic Versioning, this function parse arbitary string excluding `## [Unreleased]` and string with blank spaces. This operation simply matches to the first h2 header.
Types ¶
type SemanticVersion ¶
SemanticVersion represents major/minor/patch numbers.
func NewSemanticVersion ¶
func NewSemanticVersion(given string) (*SemanticVersion, error)
NewSemanticVersion takes arbitary string, parse and return struct.
func SortVersions ¶
func SortVersions(in []SemanticVersion) []SemanticVersion
SortVersions in ascending order with dumb algorithm.
func (SemanticVersion) Increment ¶
func (c SemanticVersion) Increment(in VersionType) SemanticVersion
Increment version according to given type. The type must be one of Major/Minor/Patch.
Given 1.2.3 as example: - Increment(Major) --> 2.2.3 - Increment(Minor) --> 1.3.3 - Increment(Patch) --> 1.2.4
func (SemanticVersion) IsEqual ¶
func (c SemanticVersion) IsEqual(in *SemanticVersion) bool
IsEqual compares internal version with given version.
func (SemanticVersion) IsGreater ¶
func (c SemanticVersion) IsGreater(in *SemanticVersion) bool
IsGreater compares internal version with given version.
type VersionType ¶
type VersionType string
VersionType corresponds to Major.Minor.Patch in Semantic Versioning 2.0.0. https://semver.org
const ( MajorVersion VersionType = "major" MinorVersion VersionType = "minor" PatchVersion VersionType = "patch" )
Exposed keys of version types.
func AliasedVersion ¶
func AliasedVersion(in string) (VersionType, error)
AliasedVersion returns the original version type or error. GitFlow idiom is currently available.