gomod

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gomod implements a notice.Collector for direct dependencies declared in go.mod.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdRunner

type CmdRunner interface {
	Run(name string, args ...string) ([]byte, error)
}

CmdRunner runs an external command and returns stdout. Tests inject a fake to keep `go mod download` out of the loop.

type Collector

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

Collector enumerates direct (non-indirect) dependencies in go.mod and builds a NOTICE entry for each by consulting the module cache via `go mod download -json`.

func New

func New(opts ...Option) *Collector

New constructs a Collector with production defaults.

func (*Collector) Collect

func (c *Collector) Collect(root string) ([]notice.Entry, error)

Collect implements notice.Collector.

func (*Collector) Name

func (c *Collector) Name() string

Name implements notice.Collector.

func (*Collector) Precheck

func (c *Collector) Precheck(root string) error

Precheck implements notice.Collector. The Go toolchain handles its own caching; we only verify that go.mod exists.

type FileSystem

type FileSystem interface {
	ReadFile(path string) ([]byte, error)
}

FileSystem is the small slice of os we depend on. Tests inject a fake to keep the host filesystem out of the loop where it would otherwise consult the real Go module cache.

type Option

type Option func(*Collector)

Option configures a Collector.

func WithFS

func WithFS(f FileSystem) Option

WithFS injects a FileSystem. Defaults to the host filesystem.

func WithRunner

func WithRunner(r CmdRunner) Option

WithRunner injects a CmdRunner. Defaults to invoking the real `go` binary.

Jump to

Keyboard shortcuts

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