gorelease

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: 16 Imported by: 0

Documentation

Overview

Package gorelease answers "what was the latest stable Go release at time T?" and "what is the latest stable Go release available now?", optionally constrained to a minor series (e.g. "1.24"). It is backed by the Go module proxy's golang.org/toolchain pseudo-module, which lists one module version per Go release x platform and exposes each release's publish time via its ".info" endpoint.

Limitations:

  • The golang.org/toolchain module only covers Go 1.21 and later (released August 2023); earlier releases are invisible to this index.
  • Only stable releases are indexed. rc and beta pre-releases are excluded entirely, both from LatestAsOf and LatestAvailable results.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoReleases = errors.New("gorelease: no matching stable Go releases")

ErrNoReleases indicates that no stable Go release matches the requested constraint - e.g. an unknown minor series, or one that only ever shipped rc/beta releases (and therefore has no stable entries in the index).

Functions

This section is empty.

Types

type Index

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

Index is a lazily-populated, memoized view over the golang.org/toolchain module's release list. It answers point-in-time "latest stable Go release" queries without re-fetching data it has already resolved.

An Index is safe for concurrent use.

func NewIndex

func NewIndex(httpClient *http.Client) *Index

NewIndex returns an Index backed by the first usable entry of the process's GOPROXY (falling back to proxy.golang.org when GOPROXY's first entry is "direct", "off", or otherwise unusable - the toolchain index is public release metadata, so this fallback carries no privacy concern). A nil httpClient falls back to a default client with a ~30s timeout.

func (*Index) LatestAsOf

func (ix *Index) LatestAsOf(ctx context.Context, t time.Time, minorConstraint string) (string, error)

LatestAsOf returns the highest stable Go release (bare form, e.g. "1.24.5") whose publish time is <= t, restricted to minorConstraint (e.g. "1.24") when non-empty. If t predates every matching release, the OLDEST matching release is returned instead of an error: callers use this to detect stdlib exposure, so it is safer to over-detect ("this looks like an old Go release") than to silently miss a release entirely.

func (*Index) LatestAvailable

func (ix *Index) LatestAvailable(ctx context.Context, minorConstraint string) (string, error)

LatestAvailable returns the highest stable Go release (bare form, e.g. "1.24.5") within minorConstraint (e.g. "1.24"; empty means unconstrained). It requires only the release list, never a .info fetch.

func (*Index) LatestAvailableAsOf

func (ix *Index) LatestAvailableAsOf(ctx context.Context, cutoff time.Time, minorConstraint string) (string, error)

LatestAvailableAsOf returns the highest stable Go release (bare form, e.g. "1.24.5") whose publish time is <= cutoff, restricted to minorConstraint (e.g. "1.24") when non-empty. Unlike LatestAsOf it is STRICT: when nothing qualifies (the cutoff predates every matching release, or the constraint has no stable releases at all) it returns an error wrapping ErrNoReleases rather than falling back to the oldest release. Callers use it to age the rebuild target back behind a publication-age margin, where under-detecting ("no release old enough yet") is the safe direction.

Jump to

Keyboard shortcuts

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