A Go library for parsing and verifying versions and version constraints
open sourceMPL-2.0free
go-version is HashiCorp's Go library for parsing versions and version constraints and checking versions against them. It compares and sorts versions, handles prerelease and build metadata, increments versions, and can strip a known prefix (such as deployment-) before parsing. Versions must follow SemVer.
Problems it solves
- check whether a version string satisfies a constraint like '>= 1.2, < 2.0' in Go
- sort a list of release versions correctly in Go, with betas before the final release
- compare two version numbers in a Go CLI to decide whether to update
- parse version tags that carry a prefix like 'deployment-v1.2.3'
Features
- parse versions and compare them (less than, greater than, equal)
- version constraints such as '>= 1.0, < 1.4'
- sort a collection of versions, prereleases included
- strip a custom prefix before parsing
- increment versions
Alternatives
The same job
These do what go-version does.
- go-semver Parse, compare and bump semantic version strings in Go
- semver (Go) Parse, sort and check semantic versions against constraints in Go
