// AllPackages returns the package path of each Go package in any source // directory of the specified build context (e.g. $GOROOT or an element // of $GOPATH). Errors are ignored. The results are sorted. // All package paths are canonical, and thus may contain "/vendor/". // // The result may include import paths for directories that contain no // *.go files, such as "archive" (in $GOROOT/src). // // All I/O is done via the build.Context file system interface, // which must be concurrency-safe. func AllPackages(ctxt *build.Context) []string { … } // ForEachPackage calls the found function with the package path of // each Go package it finds in any source directory of the specified // build context (e.g. $GOROOT or an element of $GOPATH). // All package paths are canonical, and thus may contain "/vendor/". // // If the package directory exists but could not be read, the second // argument to the found function provides the error. // // All I/O is done via the build.Context file system interface, // which must be concurrency-safe. func ForEachPackage(ctxt *build.Context, found func(importPath string, err error)) { … } type item … var ioLimit … func allPackages(ctxt *build.Context, root string, ch chan<- item) { … } // ExpandPatterns returns the set of packages matched by patterns, // which may have the following forms: // // golang.org/x/tools/cmd/guru # a single package // golang.org/x/tools/... # all packages beneath dir // ... # the entire workspace. // // Order is significant: a pattern preceded by '-' removes matching // packages from the set. For example, these patterns match all encoding // packages except encoding/xml: // // encoding/... -encoding/xml // // A trailing slash in a pattern is ignored. (Path components of Go // package names are separated by slash, not the platform's path separator.) func ExpandPatterns(ctxt *build.Context, patterns []string) map[string]bool { … }