semver #

semver

A library for working with versions in semver format.

Usage

import semver

fn main() {
    ver1 := semver.from('1.2.4') or {
        println('Invalid version')
        return
    }
    ver2 := semver.from('2.3.4') or {
        println('Invalid version')
        return
    }
    println(ver1.gt(ver2))
    println(ver2.gt(ver1))
    println(ver1.satisfies('>=1.1.0 <2.0.0'))
    println(ver2.satisfies('>=1.1.0 <2.0.0'))
    println(ver2.satisfies('>=1.1.0 <2.0.0 || >2.2.0'))
}
false
true
true
false
true

For more details see semver.v file.

fn build #

fn build(major int, minor int, patch int) Version

build returns Version structure with given major, minor and patch versions.

fn coerce #

fn coerce(input string) ?Version
  • Utilites.

fn from #

fn from(input string) ?Version
  • Constructor. from returns Version structure parsed from input string.

fn is_valid #

fn is_valid(input string) bool

enum Increment #

enum Increment {
	major
	minor
	patch
}

Enum representing type of version increment.

struct Version #

struct Version {
pub:
	major      int
	minor      int
	patch      int
	prerelease string
	metadata   string
}
  • Structures. Structure representing version in semver format.

fn (Version) increment #

fn (ver Version) increment(typ Increment) Version
  • Transformation. increment returns Version structure with incremented values.

fn (Version) satisfies #

fn (ver Version) satisfies(input string) bool
  • Comparison.

fn (Version) eq #

fn (v1 Version) eq(v2 Version) bool

fn (Version) gt #

fn (v1 Version) gt(v2 Version) bool

fn (Version) lt #

fn (v1 Version) lt(v2 Version) bool

fn (Version) ge #

fn (v1 Version) ge(v2 Version) bool

fn (Version) le #

fn (v1 Version) le(v2 Version) bool