Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


A Go (golang) library for parsing and verifying versions and version constraints.

Subscribe to updates I use go-version

Statistics on go-version

Number of watchers on Github 365
Number of open issues 10
Average time to close an issue about 2 months
Main language Go
Average time to merge a PR 20 days
Open pull requests 6+
Closed pull requests 3+
Last commit over 2 years ago
Repo Created about 6 years ago
Repo Last Updated about 2 years ago
Size 44 KB
Organization / Authorhashicorp
Page Updated
Do you use go-version? Leave a review!
View open issues (10)
View go-version activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating go-version for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Versioning Library for Go

Build Status

go-version is a library for parsing versions and version constraints, and verifying versions against a set of constraints. go-version can sort a collection of versions properly, handles prerelease/beta versions, can increment versions, etc.

Versions used with go-version must follow SemVer.

Installation and Usage

Package documentation can be found on GoDoc.

Installation can be done with a normal go get:

$ go get github.com/hashicorp/go-version

Version Parsing and Comparison

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)

Version Constraints

v1, err := version.NewVersion("1.2")

// Constraints example.
constraints, err := version.NewConstraint(">= 1.0, < 1.4")
if constraints.Check(v1) {
    fmt.Printf("%s satisfies constraints %s", v1, constraints)

Version Sorting

versionsRaw := []string{"1.1", "0.7.1", "1.4-beta", "1.4", "2"}
versions := make([]*version.Version, len(versionsRaw))
for i, raw := range versionsRaw {
    v, _ := version.NewVersion(raw)
    versions[i] = v

// After this, the versions are properly sorted

Issues and Contributing

If you find an issue with this library, please report an issue. If you'd like, we welcome any contributions. Fork this library and submit a pull request.

go-version open issues Ask a question     (View All Issues)
  • almost 4 years Store and allow retrieval of the string of the version in its original form
  • about 4 years Comparison to github.com/Masterminds/semver
go-version open pull requests (View All Pulls)
  • JSON support and BumpVersion
  • Feature/4ormoredots
  • Implement constraint logic for caret (^) and tilde (~)
  • Added GreaterThanOrEqualTo and LessThanOrEqualTo functions
  • Add JSON support for Version
  • fix pre-release checks in constraints
go-version questions on Stackoverflow (View All Questions)
  • ERROR: Unrecognized Go version
  • Ansible GVM - Go Version Manager
  • What does Go Version means?
  • How can you upgrade Go version to 1.2.1 on Nitrous.io?
  • Is there a Go version of the "MD5-based block cipher"?
  • GAE Go Version 3 API error
go-version list of languages used
Other projects in Go