package packagestest

Import Path
	go.pact.im/x/plumb/internal/packagestest (on go.dev)

Dependency Relation
	imports 10 packages, and imported by 0 packages

Involved Source Files Package packagestest is an in-memory Go package loader for tests. It type-checks source provided as a map of path → content, resolving imports against the in-memory module and a small synthetic subset of the standard library (see fakeStd), never GOROOT, a subprocess, or the disk. That keeps the fast unit tests (table-driven, golden, compile-check, fuzz, determinism) hermetic: they pass even when the test binary is built with -trimpath, which strips the baked-in GOROOT that the default disk-backed importer would otherwise need. File paths encode the package: a file at "example.com/app/x.go" belongs to the package whose import path is "example.com/app". The package name is taken from the package clause.
Package-Level Type Names (total 3, in which 2 are exported)
/* sort exporteds by: | */
Loaded is the result of loading an in-memory module. Packages []*discover.Package TypeErrors are non-fatal type-checking errors (e.g. a stale generated file). Parse errors are returned as the error result instead. func Load(files map[string]string) (*Loaded, error) func LoadShuffled(files map[string]string, shuffle ShuffleFunc) (*Loaded, error)
ShuffleFunc reorders a sequence of n elements by swapping pairs. It has the signature of math/rand/v2's (*Rand).Shuffle, so a *Rand's Shuffle method can be passed directly. func LoadShuffled(files map[string]string, shuffle ShuffleFunc) (*Loaded, error)
Package-Level Functions (total 3, in which 2 are exported)
Load parses and type-checks the given files, grouped into packages by their directory. The companion LoadShuffled additionally reorders the files, the load order, and the returned package slice to exercise determinism.
LoadShuffled is Load with an optional reordering of files within packages and of the packages themselves, used by the determinism test. When shuffle is nil the deterministic sorted order is used as-is.
Package-Level Variables (total 2, in which 1 is exported)
ErrImportCycle is returned by Load when type-checking hits an import cycle. It is a sentinel so callers classify the failure with errors.Is rather than matching message text. (The type-checker also reports the cycle as a per-import type error, but that loses the error chain.)