Documentation
¶
Overview ¶
Package goanalysis provides Go type-aware analysis via go/types.
ConvertToCallGraph and MergeCallGraphs have moved to the callgraph package to avoid a circular dependency. Import callgraph directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasGoModule ¶
HasGoModule checks if dir contains a go.mod file.
Types ¶
type LoadOpts ¶
type LoadOpts struct {
Patterns []string // package patterns to load (default: "./...")
Timeout time.Duration // override default 60s timeout
}
LoadOpts configures package loading.
type LoadResult ¶
LoadResult contains loaded packages with full type information.
func LoadPackages ¶
type Satisfaction ¶
type Satisfaction struct {
Type string // concrete (non-interface) named type, e.g. "GitHubForge"
TypeFile string // absolute path of the concrete type's declaration
Interface string // interface named type, e.g. "Forge"
}
Satisfaction is one structural interface-satisfaction fact: the named concrete type Type (declared in TypeFile) satisfies the named interface Interface. Computed via go/types, which Go's structural typing makes invisible to tree-sitter (no `implements` keyword).
Names are bare (package qualifier stripped), matching how the codegraph Symbol vertices are keyed (name + file). TypeFile is an absolute path from the FileSet; the caller maps it to repo-relative form for the graph key. The interface endpoint is resolved by the codegraph caller via the symbol table (name lookup in buildRelationshipEdges), so the interface's declaration file is not carried here.
func ComputeSatisfactions ¶
func ComputeSatisfactions(pkgs []*packages.Package) []Satisfaction
ComputeSatisfactions returns every (concrete type, interface) pair across the loaded package set where the type — by value OR by pointer — implements the interface. The empty interface (zero methods) is skipped: every type trivially satisfies it, so emitting those edges would be pure noise and O(types) blow-up.
Scope is bounded to the loaded packages (the module's own ./...), NOT the transitive dependency universe: gatherNamedNonInterface and the interface walk both iterate only pkgs, so a type T is checked only against interfaces declared in the same loaded set. This keeps the satisfaction loop at O(localTypes × localInterfaces) rather than O(types × universe).
The pairing logic mirrors mapInterfaceImpls (which builds the call-resolution concreteTypes map and discards the type→interface direction); both share the types.Implements(T, I) || types.Implements(*T, I) test.
type TypedEdge ¶
type TypedEdge struct {
CallerName string // function containing the call
CallerFile string // absolute path
CallerLine uint32 // line of the caller function definition
CalleeName string // called function/method name
CalleeFile string // absolute path (empty if external)
CalleePkg string // package path of callee
ReceiverType string // receiver type for method calls (empty for functions)
Line uint32 // line of the call site
IsInterface bool // true if this is interface dispatch
}
TypedEdge is a call edge with full type information from the Go compiler.