version

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(v1, v2 string) int

CompareVersions is a convenience function to compare two version strings

func IsUpdateAvailable

func IsUpdateAvailable(current, latest string) bool

IsUpdateAvailable is an alias for ShouldUpdate

func ShouldUpdate

func ShouldUpdate(current, latest string) bool

ShouldUpdate determines if an update is available current is the currently installed version latest is the available version

Types

type Version

type Version struct {
	// contains filtered or unexported fields
}

Version represents a semantic version with parsing and comparison capabilities

func LatestStable

func LatestStable(versions []string) *Version

LatestStable returns the latest stable version from a list

func NewVersion

func NewVersion(raw string) *Version

NewVersion creates a new Version from a raw string

func (*Version) Build

func (v *Version) Build() string

Build returns the build metadata

func (*Version) Clean

func (v *Version) Clean() string

Clean returns the cleaned version string (without v prefix or git suffix)

func (*Version) Compare

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

Compare compares this version with another Returns:

1 if v > other (v is newer)
0 if v == other

1 if v < other (other is newer) 2 if either version is invalid

func (*Version) Equals

func (v *Version) Equals(other *Version) bool

Equals checks if versions are equal

func (*Version) FullString

func (v *Version) FullString() string

FullString returns the complete version with pre-release and build

func (*Version) IsNewerThan

func (v *Version) IsNewerThan(other *Version) bool

IsNewerThan checks if this version is newer than the other

func (*Version) IsOlderThan

func (v *Version) IsOlderThan(other *Version) bool

IsOlderThan checks if this version is older than the other

func (*Version) IsPreRelease

func (v *Version) IsPreRelease() bool

IsPreRelease returns true if version is alpha/beta/rc

func (*Version) IsStable

func (v *Version) IsStable() bool

IsStable returns true if version is not pre-release

func (*Version) IsValid

func (v *Version) IsValid() bool

IsValid returns true if version was parsed successfully

func (*Version) Major

func (v *Version) Major() int64

Major returns the major version number

func (*Version) Minor

func (v *Version) Minor() int64

Minor returns the minor version number

func (*Version) Patch

func (v *Version) Patch() int64

Patch returns the patch version number

func (*Version) PreRelease

func (v *Version) PreRelease() string

PreRelease returns the pre-release identifier

func (*Version) Raw

func (v *Version) Raw() string

Raw returns the original raw version string

func (*Version) Satisfies

func (v *Version) Satisfies(constraint string) bool

Satisfies checks if version satisfies a constraint Supports: >=, >, =, <=, <

func (*Version) String

func (v *Version) String() string

String returns the version as a string (major.minor.patch only, without pre-release or build metadata)

Jump to

Keyboard shortcuts

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