discover

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package discover finds outdated modules and tool modules with `go list`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileIgnore

func CompileIgnore(patterns []string) ([]*regexp.Regexp, error)

CompileIgnore compiles the --ignore patterns, rejecting invalid ones up front rather than per module.

func Exec

func Exec(dir string, args ...string) ([]byte, error)

Exec is the one real Runner. Tests pass a closure instead.

Types

type Discoverer

type Discoverer struct {
	Run    Runner
	Dir    string
	Ignore []*regexp.Regexp
}

Discoverer lists the outdated modules of one module directory.

func (Discoverer) DirectDependencies

func (d Discoverer) DirectDependencies() (map[string]string, error)

DirectDependencies maps each direct dependency of d.Dir to its version.

func (Discoverer) MajorUpgrades

func (d Discoverer) MajorUpgrades(noCache bool) ([]module.Module, []func())

MajorUpgrades returns the major version upgrades available for d.Dir's direct dependencies, looked up through the pkg.go.dev API.

Logging is returned rather than emitted: callers run this behind a spinner, and a log line written while the spinner is drawing corrupts the line. A failed lookup is never fatal — a module the API can't answer for is one that keeps its patch and minor upgrades.

func (Discoverer) Modules

func (d Discoverer) Modules() ([]module.Module, error)

Modules returns the direct dependencies that have an update available.

func (Discoverer) Tools

func (d Discoverer) Tools() ([]module.Module, error)

Tools returns the module-backed tools that have an update available.

func (Discoverer) ToolsSupported

func (d Discoverer) ToolsSupported() (bool, error)

ToolsSupported reports whether d.Dir's toolchain supports tool modules. `go version` selects its toolchain from the go.mod of the directory it runs in, so this has to be asked per module directory: in workspace mode members can pin toolchains straddling the 1.24 tool-module gate.

func (Discoverer) Versions

func (d Discoverer) Versions(name string, after *semver.Version) ([]cooldown.VersionInfo, error)

Versions reports the tagged versions of a module newer than after, in ascending order, together with their publish times. The method value satisfies cooldown.Lookup.

type Runner

type Runner func(dir string, args ...string) ([]byte, error)

Runner runs the go command in dir and returns its standard output. Every implementation sets GOWORK=off; see Exec.

Jump to

Keyboard shortcuts

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