goversion

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package goversion provides comparison helpers for bare Go language/directive version strings as they appear in go.mod `go` directives and melange `go-version` inputs (e.g., "1.24", "1.24.5", "1.25rc1"). These functions operate on bare version strings without "v" or "go" prefixes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string) int

Compare compares two bare Go directive versions (e.g. "1.24", "1.24.5", "1.25rc1"). It returns -1, 0, or +1. Invalid versions sort below all valid versions; two invalid versions compare equal.

func IsValid

func IsValid(v string) bool

IsValid reports whether v is a valid bare Go directive version.

func Max

func Max(vs ...string) string

Max returns the highest of the given versions, ignoring invalid or empty entries. It returns "" when no valid version is present.

func Minor

func Minor(v string) string

Minor returns the major.minor language version of v (e.g. "1.25.3" -> "1.25", "1.25rc1" -> "1.25"). It returns "" for invalid input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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