go-version-lib

module
v0.0.0-...-d619d40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT

README

go-version-lib

A Go library for parsing, comparing, and manipulating software versions across many package ecosystems.

Features

  • Parse, compare, and bump semantic versions (semver)
  • Support for ecosystem-specific version schemes:
    • Debian (deb)
    • RubyGems (gem)
    • Maven (mvn)
    • npm (npm)
    • PEP 440 (pep440)
    • RPM (rpm)
    • Package URL (purl)
  • Generic version handling (version)
  • Constraints, requirements, and version collections

Installation

go get github.com/khulnasoft/go-version-lib

Quick start

package main

import (
	"fmt"

	"github.com/khulnasoft/go-version-lib/pkg/semver"
)

func main() {
	v1, _ := semver.Parse("1.2.3")
	v2, _ := semver.Parse("1.2.4")

	fmt.Println(v1.LessThan(v2)) // true
	fmt.Println(v1.String())     // 1.2.3
}

Packages

Package Description
pkg/version Core version parsing and comparison
pkg/semver Semantic Versioning support
pkg/deb Debian package versions
pkg/gem RubyGems versions
pkg/mvn Maven artifact versions
pkg/npm npm package versions
pkg/pep440 PEP 440 (Python) versions
pkg/rpm RPM package versions
pkg/purl Package URLs
pkg/part Version part primitives
pkg/prerelease Pre-release comparison
pkg/reference Version references

CLI

A command-line tool is provided under cmd/goversion:

go run ./cmd/goversion/ parse 1.2.3
go run ./cmd/goversion/ compare 1.2.3 1.2.4
go run ./cmd/goversion/ check 1.2.3 '>=1.2.0'
go run ./cmd/goversion/ detect 1.2.3

Development

make bootstrap   # install tooling
make test        # run unit tests
make lint        # run static analysis
make format      # format source

License

MIT License. See LICENSE.

Directories

Path Synopsis
cmd
goversion command
Command goversion is a CLI for parsing, comparing, and checking software versions using github.com/khulnasoft/go-version-lib.
Command goversion is a CLI for parsing, comparing, and checking software versions using github.com/khulnasoft/go-version-lib.
pkg
cargo
Package cargo provides semantic version support for the cargo ecosystem.
Package cargo provides semantic version support for the cargo ecosystem.
deb
gem
golang
Package golang provides helpers for Go module pseudo-versions.
Package golang provides helpers for Go module pseudo-versions.
hex
Package hex provides semantic version support for the hex ecosystem.
Package hex provides semantic version support for the hex ecosystem.
mvn
npm
nuget
Package nuget implements NuGet package version parsing and comparison.
Package nuget implements NuGet package version parsing and comparison.
pub
Package pub provides semantic version support for the pub ecosystem.
Package pub provides semantic version support for the pub ecosystem.
purl
Package purl implements Package URLs (purl) as defined by https://github.com/package-url/packageurl-spec
Package purl implements Package URLs (purl) as defined by https://github.com/package-url/packageurl-spec
rpm
versionrange
Package versionrange provides an ecosystem-agnostic model for version ranges.
Package versionrange provides an ecosystem-agnostic model for version ranges.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL