talira

go-semver

Parse, compare and bump semantic version strings in Go

open sourceApache-2.0free

go-semver is a small Go library from CoreOS for semantic versions. It parses version strings into a Version with major, minor, patch, pre-release and metadata parts, compares and sorts them (pre-release identifiers included), and bumps the major, minor or patch number. A Version also works as a command-line flag value and marshals to and from JSON and YAML.

Problems it solves

  • compare two version strings correctly in my Go program
  • sort a list of release versions in Go, with pre-releases in the right order
  • bump the patch or minor version of a release from a Go tool

Features

  • Parses semantic version strings, with pre-release and metadata parts
  • Compare, Equal and LessThan, with pre-release precedence
  • Sorts lists of versions
  • BumpMajor, BumpMinor and BumpPatch
  • Works as a flag.Value and marshals to JSON and YAML

Alternatives

The same job

These do what go-semver does.

  1. go-version A Go library for parsing and verifying versions and version constraints
  2. semver (Go) Parse, sort and check semantic versions against constraints in Go

Compare go-semver with the top 3