Package importgraph computes the forward and reverse import dependency graphs for all packages in a Go workspace.
Internal call graph ▹
Internal call graph ▾
In the call graph viewer below, each node is a function belonging to this package and its children are the functions it calls—perhaps dynamically.
The root nodes are the entry points of the package: functions that may be called from outside the package. There may be non-exported or anonymous functions among them if they are called dynamically from another package.
Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring
Functions may be omitted if they were determined to be unreachable in the particular programs or tests that were analyzed.
func Build(ctxt *build.Context) (forward, reverse Graph, errors map[string]error)
Build scans the specified Go workspace and builds the forward and reverse import dependency graphs for all its packages. It also returns a mapping from canonical import paths to errors for packages whose loading was not entirely successful. A package may appear in the graph and in the errors mapping. All package paths are canonical and may contain "/vendor/".
A Graph is an import dependency graph, either forward or reverse.
The graph maps each node (a package import path) to the set of its successors in the graph. For a forward graph, this is the set of imported packages (prerequisites); for a reverse graph, it is the set of importing packages (clients).
Graph construction inspects all imports in each package's directory, including those in _test.go files, so the resulting graph may be cyclic.
type Graph map[string]map[string]bool
func (g Graph) Search(roots ...string) map[string]bool
Search returns all the nodes of the graph reachable from any of the specified roots, by following edges forwards. Relationally, this is the reflexive transitive closure.