Parse, sort and check semantic versions against constraints in Go
open sourceMITfree
Masterminds semver is a Go package for working with Semantic Versions: it parses them (strictly, or coercing forms such as v1.2 to 1.2.0), sorts them, and checks whether a version fits a set of constraints, with ranges such as hyphen ranges, wildcards and the ~ and ^ shorthands. Version 3 focuses on constraint compatibility with range handling in tools from other languages. Import it as github.com/Masterminds/semver/v3; the 1.x line is no longer maintained.
Problems it solves
- check whether a version string satisfies a range like ^1.2 in Go
- sort release tags by semantic version in my Go tool
- parse sloppy version strings like v1.2 into proper semver in Go
Features
- strict and coercing version parsing
- sorting versions
- constraint checking with hyphen ranges, wildcards, ~ and ^
- optional v prefix
Limitations
- The 1.x line is no longer maintained; use v31
Alternatives
The same job
These do what semver (Go) does.
- go-semver Parse, compare and bump semantic version strings in Go
- go-version A Go library for parsing and verifying versions and version constraints
