Documentation ¶
Overview ¶
tools mainly contains variations on code found under golang.org/x/tools, but modified to be optimized for our usecase.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildReverseImportGraph ¶
func BuildReverseImportGraph(ctxt *build.Context, findPackage FindPackageFunc, dir string) importgraph.Graph
BuildReverseImportGraph is much like importgraph.Build, except: * it only returns the reverse graph * it does not return errors * it uses a custom FindPackageFunc * it only searches pkgs under dir (but graph can contain pkgs outside of dir) * it searches xtest pkgs as well
The code is adapted from the original function.
func ListPkgsUnderDir ¶
ListPkgsUnderDir is buildutil.ExpandPattern(ctxt, []string{dir + "/..."}). The implementation is modified from the upstream buildutil.ExpandPattern so we can be much faster. buildutil.ExpandPattern looks at all directories under GOPATH if there is a `...` pattern. This instead only explores the directories under dir. In future buildutil.ExpandPattern may be more performant (there are TODOs for it).
Types ¶
type FindPackageFunc ¶
type FindPackageFunc func(ctxt *build.Context, fromDir, importPath string, mode build.ImportMode) (*build.Package, error)
FindPackageFunc is the same type as loader.Config.FindPackage. Refer to its docstring.