Hashicorp go-version

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

Installation

go get github.com/hashicorp/go-version

Programming Model

v1, err := version.NewVersion("1.2")
v2, err := version.NewVersion("1.5+metadata")

// Comparison example. There is also GreaterThan, Equal, and just
// a simple Compare that returns an int allowing easy >=, <=, etc.
if v1.LessThan(v2) {
    fmt.Printf("%s is less than %s", v1, v2)
}