package discover

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

Dependency Relation
	imports 10 packages, and imported by 6 packages

Involved Source Files Package discover is plumb's first phase: it scans loaded packages for //plumb:<name> directives and turns each tagged declaration into a Provider, the surface-independent description the solve phase wires together. It reads syntax and type information but makes no wiring decisions. provider.go
Package-Level Type Names (total 3, all are exported)
/* sort exporteds by: | */
Package is one loaded, type-checked Go package as the core consumes it. The loaders (the real go/packages loader and the in-memory test loader) produce values of this shape; the core never loads anything itself. It is discover's input contract (the first phase defines what a loaded package must carry), and the later phases and the cli read the same shape. Fset is the file set the package's positions live in. All scanned packages share one Fset so positions are globally comparable. Info carries the type information gathered during checking (Defs, Uses, Types, Selections). Name is the package clause name (e.g. "app"). PkgPath is the package's import path (e.g. "example.com/app"). It is the identity used to decide qualification against the destination. Syntax is the parsed source of the package (with comments), used to find directives and the declarations they attach to. Types is the type-checked package, used to resolve provider and signature types. func Analyze(pkgs []*Package, destPath, outputBase string) ([]*Provider, *diag.Error) func FileBase(pkg *Package, file *ast.File) string func go.pact.im/x/plumb/internal/emit.File(importPath, packageName string, pkgs []*Package, plans []*solve.Plan, dest *solve.DestInfo) *emit.Result func go.pact.im/x/plumb/internal/gen.Generate(opts gen.Options, pkgs []*Package) (*emit.Result, error)
Provider is one discovered directive occurrence. A declaration tagged with N directives yields N providers (one per set name), so each provider belongs to exactly one set. // KindConvert: the source type consumed // KindConvert: the target type produced // KindStruct: the directive's declared type (a *Named or *Alias), rendered as written Origin objects, by kind. Only the fields relevant to Kind are set. // KindFunc, KindMethod Kind ProviderKind // human-readable name for the -v report and diagnostics // KindMethod (receiver), KindField (struct): a *Named, or a *Alias when the member is on an alias to an anonymous composite // the declaring package // identifying position, for ordering and diagnostics SetName string // KindSymbol (a var or typed const), KindField (the field) Tparams are the provider's type parameters (from the function or the owner type). nil/empty means the provider is concrete. Generic reports whether the provider is a template. func Analyze(pkgs []*Package, destPath, outputBase string) ([]*Provider, *diag.Error) func go.pact.im/x/plumb/internal/solve.Set(name string, provs []*Provider, destPath, outputBase string, dest *solve.DestInfo, ctxt *types.Context) (*solve.Plan, *diag.Error)
ProviderKind enumerates the surface forms a directive can tag. They all reduce to the same abstraction (inputs, results, a render rule), which is what lets the wiring code in the solve package ignore the kind almost entirely. ( ProviderKind) String() string ProviderKind : expvar.Var ProviderKind : fmt.Stringer const KindConvert const KindField const KindFunc const KindMethod const KindStruct const KindSymbol
Package-Level Functions (total 22, in which 2 are exported)
Analyze scans every package for directives and builds the provider list. It returns a located error for any malformed provider. Packages are scanned in import-path order and files in name order, and scanFile returns the source-earliest fault within a file, so when the input has more than one fault the diagnostic returned is a fixed choice: the source-earliest fault of the first file (in that order) to have one. This choice does not depend on the order the loader presented packages and files (which it does not promise); every phase anchors ordering to source position. The sorts run over copies, leaving the loaded packages untouched. Provider order is irrelevant downstream (solve re-sorts each set by position), so only diagnostic selection is affected. The file being overwritten (the prior generated output, identified by the base name of -output within the destination package) is skipped, so plumb never feeds its own previous output back as input. (plumb does not emit directives, so this only matters for a hand-edited or stray directive in that file.)
FileBase returns the base name of the file containing the given syntax tree.
Package-Level Constants (total 6, all are exported)
The provider kinds, one per surface form a directive can tag.
The provider kinds, one per surface form a directive can tag.
The provider kinds, one per surface form a directive can tag.
The provider kinds, one per surface form a directive can tag.
The provider kinds, one per surface form a directive can tag.
The provider kinds, one per surface form a directive can tag.