Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

import (
    "github.com/mcuadros/go-version"
)
version.Normalize("10.4.13-b")
10.4.13.0-beta
version.CompareSimple("1.2", "1.0.1")
1
version.CompareSimple("1.0rc1", "1.0")
-1
version.Compare("1.0-dev", "1.0", "<")
true
version.Compare("1.0rc1", "1.0", ">=")
false
version.Compare("2.3.4", "v3.1.2", "<")
true

Version Constraints

c := version.NewConstrainGroupFromString(">2.0,<=3.0")
c.Match("2.5.0beta")
//Returns: true

c := version.NewConstrainGroupFromString("~1.2.3")
c.Match("1.2.3.5")
//Returns: true

Sort Versions

arr := []string{"1.10-dev", "1.0rc1", "1.0", "1.0-dev"}
arr
[1.10-dev 1.0rc1 1.0 1.0-dev]
version.Sort(arr)
arr
[1.0-dev 1.0rc1 1.0 1.10-dev]