semver

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package semver compares release version strings such as "v1.2.3" or "0.4.0-beta.2" by semantic-versioning precedence.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string) (cmp int, ok bool)

Compare orders two release versions such as "v1.2.3" or "0.4.0-beta.2" by semver precedence: -1 if a < b, 0 if equal, 1 if a > b. ok is false when either is not a release version (for example "dev").

Example
package main

import (
	"fmt"

	"github.com/GLINCKER/levelrail/kit/semver"
)

func main() {
	fmt.Println(semver.Compare("v1.2.3", "v1.10.0"))
	fmt.Println(semver.Compare("0.4.0-beta.2", "0.4.0"))
	fmt.Println(semver.Compare("dev", "v1.0.0"))
}
Output:
-1 true
-1 true
0 false

Types

This section is empty.

Jump to

Keyboard shortcuts

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