golang

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 26 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decomposer

type Decomposer struct{}

func New

func New() *Decomposer

func (*Decomposer) BuildNodeList added in v0.3.3

func (d *Decomposer) BuildNodeList(set *ModuleSet, opts *api.DecomposerOptions) (*sbom.NodeList, error)

BuildNodeList renders a module set as a protobom NodeList: a root node for the main module, the stdlib at the set's Go version, one node per module reached through the graph with its checksums, and typed edges between them. Edges come from each module's go.mod, read from the local module cache and, when the networking level allows, from the module proxy; with networking enabled, dependency nodes are also enriched with license and source repository data.

func (*Decomposer) DefaultOptions

func (d *Decomposer) DefaultOptions() any

func (*Decomposer) Extract

func (d *Decomposer) Extract(opts *api.DecomposerOptions) (*sbom.NodeList, error)

Extract parses the local go.mod file, fetches dependency information from the Go module proxy, and builds the complete dependency graph as a protobom NodeList.

func (*Decomposer) FindCodeBases

func (d *Decomposer) FindCodeBases(index *code.PathIndex) ([]string, error)

func (*Decomposer) Requirements

func (d *Decomposer) Requirements(_ *api.DecomposerOptions) []api.Requirement

Requirements returns the requirements for the decomposer. No external binary required - uses pure Go implementation.

type Module added in v0.3.3

type Module struct {
	Path    string
	Version string
	Sums    []string
}

Module identifies one Go module at one version. Sums carries the module's checksums the way go.sum and Go binaries record them, "h1:" prefixed.

func (Module) Key added in v0.3.3

func (m Module) Key() string

Key returns the module in the module@version form the graph is keyed by.

type ModuleSet added in v0.3.3

type ModuleSet struct {
	// Main is the module the graph is rooted at. Only its path is read.
	Main Module

	// GoVersion is the Go release the program targets, without the "go"
	// prefix ("1.24.0"). When set, the root gets a stdlib dependency at
	// that version.
	GoVersion string

	// Requires lists the modules the main module requires. Each becomes
	// an edge from the root.
	Requires []Module

	// Modules lists every module in the build, Requires included. This is
	// the set edges are resolved within: a requirement of one of these
	// modules only becomes an edge when its target is also in the set.
	Modules []Module

	// Replaces maps a module path, or a module@version, to its replacement.
	// It is consulted when matching a module's requirements against the
	// set, so replaced paths resolve to the module actually built.
	Replaces map[string]Replacement
}

ModuleSet is the input to the Go graph builder: a program's main module and the modules built into it. A go.mod/go.sum pair reduces to one, and so does the build info embedded in a Go binary, which is what lets the same builder render both.

Edges among Modules are resolved from each module's own go.mod (see resolveGraph). A module that no edge reaches, not even from the root, is not emitted; list every module a flat inventory must show under Requires.

type Options

type Options struct {
	IncludeGo   bool
	ProxyURL    string       // default: https://proxy.golang.org
	HTTPClient  *http.Client // allow HTTP custom client for testing
	Concurrency int          // number of parallel HTTP requests (default: 10)

	// PreferModuleCache reads dependency go.mod files from the local Go
	// module cache before asking the proxy. The cache holds a copy the
	// go command has already verified against go.sum, so the data is the
	// same, but the proxy stays authoritative unless this is set.
	PreferModuleCache bool
}

Options configures the Go dependency extraction

type Replacement added in v0.3.3

type Replacement struct {
	Path    string
	Version string
}

Replacement is the target of a replace directive: the module path and version that stand in for the replaced module. An empty Path keeps the original path and replaces the version alone.

Jump to

Keyboard shortcuts

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