var ignoreVendor … const trace … type Config … type PkgSpec … type Program … type PackageInfo … func (info *PackageInfo) String() string { … } func (info *PackageInfo) appendError(err error) { … } func (conf *Config) fset() *token.FileSet { … } // ParseFile is a convenience function (intended for testing) that invokes // the parser using the Config's FileSet, which is initialized if nil. // // src specifies the parser input as a string, []byte, or io.Reader, and // filename is its apparent name. If src is nil, the contents of // filename are read from the file system. func (conf *Config) ParseFile(filename string, src interface{ … } const FromArgsUsage … // FromArgs interprets args as a set of initial packages to load from // source and updates the configuration. It returns the list of // unconsumed arguments. // // It is intended for use in command-line interfaces that require a // set of initial packages to be specified; see FromArgsUsage message // for details. // // Only superficial errors are reported at this stage; errors dependent // on I/O are detected during Load. func (conf *Config) FromArgs(args []string, xtest bool) ([]string, error) { … } // CreateFromFilenames is a convenience function that adds // a conf.CreatePkgs entry to create a package of the specified *.go // files. func (conf *Config) CreateFromFilenames(path string, filenames ...string) { … } // CreateFromFiles is a convenience function that adds a conf.CreatePkgs // entry to create package of the specified path and parsed files. func (conf *Config) CreateFromFiles(path string, files ...*ast.File) { … } // ImportWithTests is a convenience function that adds path to // ImportPkgs, the set of initial source packages located relative to // $GOPATH. The package will be augmented by any *_test.go files in // its directory that contain a "package x" (not "package x_test") // declaration. // // In addition, if any *_test.go files contain a "package x_test" // declaration, an additional package comprising just those files will // be added to CreatePkgs. func (conf *Config) ImportWithTests(path string) { … } // Import is a convenience function that adds path to ImportPkgs, the // set of initial packages that will be imported from source. func (conf *Config) Import(path string) { … } func (conf *Config) addImport(path string, tests bool) { … } // PathEnclosingInterval returns the PackageInfo and ast.Node that // contain source interval [start, end), and all the node's ancestors // up to the AST root. It searches all ast.Files of all packages in prog. // exact is defined as for astutil.PathEnclosingInterval. // // The zero value is returned if not found. func (prog *Program) PathEnclosingInterval(start, end token.Pos) (pkg *PackageInfo, path []ast.Node, exact bool) { … } // InitialPackages returns a new slice containing the set of initial // packages (Created + Imported) in unspecified order. func (prog *Program) InitialPackages() []*PackageInfo { … } // Package returns the ASTs and results of type checking for the // specified package. func (prog *Program) Package(path string) *PackageInfo { … } type importer … type findpkgKey … type findpkgValue … type importInfo … // awaitCompletion blocks until ii is complete, // i.e. the info field is safe to inspect. func (ii *importInfo) awaitCompletion() { … } // Complete marks ii as complete. // Its info and err fields will not be subsequently updated. func (ii *importInfo) Complete(info *PackageInfo) { … } type importError … // Load creates the initial packages specified by conf.{Create,Import}Pkgs, // loading their dependencies packages as needed. // // On success, Load returns a Program containing a PackageInfo for // each package. On failure, it returns an error. // // If AllowErrors is true, Load will return a Program even if some // packages contained I/O, parser or type errors, or if dependencies // were missing. (Such errors are accessible via PackageInfo.Errors. If // false, Load will fail if any package had an error. // // It is an error if no packages were loaded. func (conf *Config) Load() (*Program, error) { … } type byImportPath … func (b byImportPath) Len() int { … } func (b byImportPath) Less(i, j int) bool { … } func (b byImportPath) Swap(i, j int) { … } // markErrorFreePackages sets the TransitivelyErrorFree flag on all // applicable packages. func markErrorFreePackages(allPackages map[*types.Package]*PackageInfo) { … } // build returns the effective build context. func (conf *Config) build() *build.Context { … } // parsePackageFiles enumerates the files belonging to package path, // then loads, parses and returns them, plus a list of I/O or parse // errors that were encountered. // // 'which' indicates which files to include: // // 'g': include non-test *.go source files (GoFiles + processed CgoFiles) // 't': include in-package *_test.go source files (TestGoFiles) // 'x': include external *_test.go source files. (XTestGoFiles) func (conf *Config) parsePackageFiles(bp *build.Package, which rune) ([]*ast.File, []error) { … } // doImport imports the package denoted by path. // It implements the types.Importer signature. // // It returns an error if a package could not be created // (e.g. go/build or parse error), but type errors are reported via // the types.Config.Error callback (the first of which is also saved // in the package's PackageInfo). // // Idempotent. func (imp *importer) doImport(from *PackageInfo, to string) (*types.Package, error) { … } // findPackage locates the package denoted by the importPath in the // specified directory. func (imp *importer) findPackage(importPath, fromDir string, mode build.ImportMode) (*build.Package, error) { … } // importAll loads, parses, and type-checks the specified packages in // parallel and returns their completed importInfos in unspecified order. // // fromPath is the package path of the importing package, if it is // importable, "" otherwise. It is used for cycle detection. // // fromDir is the directory containing the import declaration that // caused these imports. func (imp *importer) importAll(fromPath, fromDir string, imports map[string]bool, mode build.ImportMode) (infos []*PackageInfo, errors []importError) { … } // findPath returns an arbitrary path from 'from' to 'to' in the import // graph, or nil if there was none. func (imp *importer) findPath(from, to string) []string { … } // startLoad initiates the loading, parsing and type-checking of the // specified package and its dependencies, if it has not already begun. // // It returns an importInfo, not necessarily in a completed state. The // caller must call awaitCompletion() before accessing its info field. // // startLoad is concurrency-safe and idempotent. func (imp *importer) startLoad(bp *build.Package) *importInfo { … } // load implements package loading by parsing Go source files // located by go/build. func (imp *importer) load(bp *build.Package) *PackageInfo { … } // addFiles adds and type-checks the specified files to info, loading // their dependencies if needed. The order of files determines the // package initialization order. It may be called multiple times on the // same package. Errors are appended to the info.Errors field. // // cycleCheck determines whether the imports within files create // dependency edges that should be checked for potential cycles. func (imp *importer) addFiles(info *PackageInfo, files []*ast.File, cycleCheck bool) { … } func (imp *importer) newPackageInfo(path, dir string) *PackageInfo { … } type closure … func (c closure) Import(to string) (*types.Package, error) { … }