goversify

module
v0.0.0-...-b7b4cec Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0

README ΒΆ

Goversify

Build Status Go Report Card Go Reference License GitHub Stars

Goversify is a powerful Go library for parsing, comparing, and validating version constraints. It supports Semantic Versioning (SemVer) and extended versioning schemes, making it ideal for version management and dependency resolution.

Features

  • βœ… Strict SemVer Parsing: Ensures compliance with Semantic Versioning.
  • βœ… Version Sorting & Comparison: Handles pre-release versions correctly.
  • βœ… Flexible Constraints: Supports logical operators (>, <, >=, <=, !=, ~, ^), wildcards (x, X, *), and complex constraints (AND & OR).
  • βœ… Extended Versioning: Supports versions beyond MAJOR.MINOR.PATCH.
  • βœ… Go-Native & Lightweight: No external dependencies.

πŸ“– Table of Contents


πŸš€ Installation

go get github.com/khulnasoft/goversify

πŸ› οΈ Usage

SemVer
v1, _ := semver.Parse("1.2.0")
v2, _ := semver.Parse("1.2.1")

if v1.LessThan(v2) {
    fmt.Printf("%s is less than %s", v1, v2)
}
Sorting Versions
versionsRaw := []string{"1.1.0", "0.7.1", "1.4.0", "1.4.0-alpha"}
versions := make([]semver.Version, len(versionsRaw))
for i, raw := range versionsRaw {
    v, _ := semver.Parse(raw)
    versions[i] = v
}
sort.Sort(semver.Collection(versions))
Constraint Validation
v, _ := semver.Parse("2.1.0")
c, _ := semver.NewConstraints(">= 1.0, < 1.4 || > 2.0")

if c.Check(v) {
    fmt.Printf("%s satisfies constraints '%s'", v, c)
}

🎯 Supported Constraint Operators

  • = : Exact match
  • != : Not equal
  • > / < : Greater / Less than
  • >= / <= : Greater / Less than or equal
  • ^ : Compatible updates (^1.2.3 β†’ >=1.2.3, <2.0.0)
  • ~ : Patch-level updates (~1.2.3 β†’ >=1.2.3, <1.3.0)
  • *, x, X : Wildcard support (2.0.x β†’ >=2.0.0, <2.1.0)

πŸ“Œ Examples

Check out the examples directory for more in-depth usage.


πŸ“œ License

Goversify is licensed under the MIT License.


🌟 Contribute

We welcome contributions! Feel free to open issues and submit PRs. 😊

Directories ΒΆ

Path Synopsis
cmd
semver command
version command
examples
semver command
version command
pkg

Jump to

Keyboard shortcuts

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