callgraph

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLoadFailed = errors.New("callgraph: go/packages load failed")

ErrLoadFailed is the exported sentinel returned when go/packages fails to load any usable package. Callers catch it via errors.Is and fall back to the gopls --calls tier (never a hard CLI error).

Functions

This section is empty.

Types

type CallEdge

type CallEdge struct {
	CallerFile, CallerSymbol string
	CallerLine               int
	CalleeFile, CalleeSymbol string
}

CallEdge is one resolved caller→callee relationship in the typed call graph. It carries enough structure to build SymbolCallers via the root package's TypedGraphToSymbolCallers adapter (Decision 3).

func Build

func Build(ctx context.Context, root string) ([]CallEdge, error)

Build returns the type-checked whole-program call graph for the module rooted at root, computed with go/packages (LoadSyntax) → go/ssa → Class Hierarchy Analysis (precise-callgraph.md Decisions 1 and 2).

Loading is fail-open: a package with type errors is skipped with a single stderr warning and the remaining packages are still analyzed. Only a total failure — packages.Load returning an error, or zero usable packages — returns ErrLoadFailed, which the caller catches to fall back to the gopls --calls tier.

Jump to

Keyboard shortcuts

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