semver functions

These functions allow user you to parse a semantic version string or test it with constraint.

It’s implemented with the https://github.com/Masterminds/semver library.

semver.Semver(unreleased)

Unreleased: This function is in development, and not yet available in released builds of gomplate.

Returns a semantic version struct holding the input version string.

The returned struct are defined at: semver.Version.

Usage

semver.Semver input
input | semver.Semver

Arguments

name description
input (required) The input to parse

Examples

$ gomplate -i '{{ semver.Semver "v1.1.1"}}'
1.1.1
$ gomplate -i '{{ (semver.Semver "v1.1.1").Major }}'
1
$ gomplate -i 'the pre release version is {{ ("v1.1.1" | semver.Semver).SetPrerelease "beta.1" }}'
the pre release version is 1.1.1-beta.1

semver.CheckConstraint(unreleased)

Unreleased: This function is in development, and not yet available in released builds of gomplate.

Test whether the input version matchs the constraint.

Ref: https://github.com/Masterminds/semver#checking-version-constraints

Usage

semver.CheckConstraint constraint input
input | semver.CheckConstraint constraint

Arguments

name description
constraint (required) The constraints expression to test.
input (required) The input semantic version string to test.

Examples

$ gomplate -i '{{ semver.CheckConstraint "> 1.0" "v1.1.1" }}'
true
$ gomplate -i '{{ semver.CheckConstraint "> 1.0, <1.1" "v1.1.1" }}'
false
$ gomplate -i '{{ "v1.1.1" | semver.CheckConstraint "> 1.0" }}'
true