Help us shape the future of Go! Take the 2026 Go Developer Survey

goversion

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package goversion answers questions about the Go toolchain: whether it is new enough, and which Go version a tool's modfile should declare.

Index

Constants

View Source
const Inherit = "inherit"

Inherit is the go version setting that takes the version from the project.

View Source
const Min = "1.24"

Min is the oldest Go gotools can manage tools with.

Variables

This section is empty.

Functions

func Lang

func Lang(goversion string) string

Lang turns `go env GOVERSION` output into a go-directive language version: "go1.27.0" -> "1.27", "go1.27rc1" -> "1.27", "devel go1.28-abc123 Tue ..." -> "1.28". It returns "" when no Go version is present.

func MeetsMin

func MeetsMin(actual, required string) (bool, bool)

MeetsMin compares X.Y numerically, using the first X.Y pair in each string ("1.24.3", "go1.24", "devel go1.26-abc"). The second result is false when either side has no X.Y pair; the first is then false too.

func Require

func Require(ctx context.Context, r gocmd.Runner, dir string) error

Require checks that go is installed and at least Min. Every failure is an Environment error.

func Resolve

func Resolve(ctx context.Context, r gocmd.Runner, pinned, root string) (string, error)

Resolve is the Go version a tool's modfile declares. A pinned version wins; Inherit (or empty) takes the root go.mod's go directive, falling back to the running toolchain's language version (major.minor).

func Valid

func Valid(v string) bool

Valid reports whether v is a version a go directive can carry, such as "1.24" or "1.24.3".

Types

This section is empty.

Jump to

Keyboard shortcuts

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