version

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package version provides semantic version parsing and manipulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(a, b string) (int, error)

CompareVersions compares two version strings and returns their relative ordering. It returns -1 if a < b, 0 if a == b, and 1 if a > b. If either version string cannot be parsed, an error is returned with context indicating which version failed to parse.

func IsGreaterE

func IsGreaterE(a, b string) (bool, error)

IsGreaterE returns true if version a is greater than version b, along with any error that occurred during parsing. This is the preferred function for new code as it allows callers to distinguish between "version A is not greater" and "invalid version string".

If an error is returned, the boolean result should be ignored.

Types

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

Version represents a semantic version.

func Parse

func Parse(s string) (*Version, error)

Parse parses a semantic version string.

func (*Version) Bump

func (v *Version) Bump(bumpType string) (*Version, error)

Bump returns a new version with the specified component bumped.

func (*Version) Compare

func (v *Version) Compare(other *Version) int

Compare compares two versions. Returns -1 if v < other, 0 if v == other, 1 if v > other.

func (*Version) String

func (v *Version) String() string

String returns the version as a string.

Jump to

Keyboard shortcuts

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