tools

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: MIT Imports: 7 Imported by: 8

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

func ListPkgsUnderDir(ctxt *build.Context, dir string) []string

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.

Jump to

Keyboard shortcuts

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