pkgload

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pkgload wraps golang.org/x/tools/go/packages.Load with lagotto's --tags and --exclude conventions. Detectors receive the already-filtered slice of *packages.Package and do not interact with the loader directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckToolchain added in v0.2.4

func CheckToolchain(root string) error

CheckToolchain rejects a target module whose go directive is newer than the Go toolchain embedded in the Lagotto binary. Without this preflight, go/packages can emit hundreds of misleading syntax and type errors when an old release audits newer language features.

func Load

func Load(root, tags string, exclude []string) ([]*packages.Package, []string, error)

Load loads all packages under root with the given build tags and returns those whose import paths do not match any path segment in exclude. Excluded packages are filtered here so detectors do not have to repeat the check.

The second return value collects per-package load errors (syntax errors, type errors, unresolved imports) from the packages that were kept. These do not abort the audit — detectors still run on whatever type-checked — but callers must surface them so a broken package is distinguishable from a clean one.

func LoadPatterns added in v0.2.4

func LoadPatterns(root, tags string, exclude, patterns []string) ([]*packages.Package, []string, error)

LoadPatterns fully loads only the requested package import paths. Audit uses this in bounded batches so TypesInfo for a large module is not retained for every package at once.

func LoadTypes added in v0.2.4

func LoadTypes(root, tags string, exclude []string) ([]*packages.Package, []string, error)

LoadTypes loads module-wide type metadata and declaration-only syntax without TypesInfo maps or implementation bodies. It is sufficient for receiver-layout detectors and substantially smaller than a full load.

func ShouldExclude

func ShouldExclude(path string, exclude []string) bool

ShouldExclude reports whether any non-empty pattern in exclude matches a run of complete path segments in path. Matching is segment-anchored, not substring: "gen" excludes "a/gen/b" but not "a/agent/b", and "design/generated" excludes "x/design/generated" but not "x/redesign/generated". Used by Load and by filesystem-walking detectors that inspect directories outside the loaded package set.

func ValidateTags added in v0.2.0

func ValidateTags(tags string) error

ValidateTags rejects malformed --tags values before they are handed to the go toolchain, whose own error ("go: -tags space-separated list contains comma") leaks build plumbing the user never invoked. Accepts the empty string (no tags) and comma-separated identifiers of letters, digits, underscores, and dots.

Types

This section is empty.

Jump to

Keyboard shortcuts

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