toolchain

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package toolchain builds a resolve.Graph by running an ecosystem's own tools on a manifest, such as the go command on go.mod or mvn on pom.xml, for projects whose lockfile does not record the whole graph.

It runs build tooling on files the scanned repository controls, and some tools run the repository's own code, such as build scripts and plugins, so callers run it inside an isolated sandbox. It never needs credentials: the caller points the tools at a registry or mirror through Options.Env. Each tool run has a timeout, and Limits bounds what is read from it.

A tool that is missing, fails, times out or prints too much makes its root unknown; one that cannot reach the registry makes it partial, with what the tool resolved without it. Resolve never fails because of a tool. A root's Manifest and Lockfile are both the manifest's path, since the tool, not a lockfile, resolved it. A Maven reactor has one root per module, each with the module's pom.xml as both.

A go.work is ignored (GOWORK=off): each go.mod resolves on its own, and the workspace's other modules are not local nodes. They appear as the versions go.mod requires, or as local nodes only through a directory replace.

Index

Constants

View Source
const DefaultTimeout = 10 * time.Minute

DefaultTimeout bounds each tool run when Options.Timeout is zero.

Variables

View Source
var ErrUnsupported = errors.New("unsupported manifest")

ErrUnsupported is returned for a manifest whose base name has no tool.

Functions

func Resolve

func Resolve(ctx context.Context, dir, manifest string, opts Options) (resolve.Graph, error)

Resolve runs the ecosystem's tools on the manifest at manifest, a slash path relative to dir. The only error is ErrUnsupported; tool problems are reported on the roots. When ctx is cancelled it returns the graph built so far, with the roots it stopped short of reported as timed out.

func Supported

func Supported(manifest string) bool

Supported reports whether manifest's base name is one this package resolves.

Types

type Limits

type Limits struct {
	MaxOutput int64 // stdout or stderr of one tool run, or a file it writes; more makes the root unknown (too_large)
	MaxNodes  int   // nodes kept; reaching it makes the roots partial (node_limit)
	MaxEdges  int   // edges kept; reaching it makes the roots partial (edge_limit)
}

Limits bounds the output read from a tool and the graph built from it. A Maven reactor's modules are resolved apart, so MaxNodes and MaxEdges bound each module's graph, not the merged one.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns limits that fit any real project: 64 MiB of output, 50,000 nodes and 500,000 edges.

type Options

type Options struct {
	Timeout time.Duration // per tool run; zero means DefaultTimeout
	// Env is added to the process environment after each tool's defaults, so
	// its values win. It is where the caller sets the registry or mirror,
	// such as GOPROXY, and may override a default, such as GOFLAGS.
	Env    []string
	Limits Limits // zero means DefaultLimits
}

Options configures Resolve.

Jump to

Keyboard shortcuts

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