type LoadMode … const NeedName … const NeedFiles … const NeedCompiledGoFiles … const NeedImports … const NeedDeps … const NeedExportsFile … const NeedTypes … const NeedSyntax … const NeedTypesInfo … const NeedTypesSizes … const typecheckCgo … const NeedModule … const LoadFiles … const LoadImports … const LoadTypes … const LoadSyntax … const LoadAllSyntax … type Config … type driver … type driverResponse … // Load loads and returns the Go packages named by the given patterns. // // Config specifies loading options; // nil behaves the same as an empty Config. // // Load returns an error if any of the patterns was invalid // as defined by the underlying build system. // It may return an empty list of packages without an error, // for instance for an empty expansion of a valid wildcard. // Errors associated with a particular package are recorded in the // corresponding Package's Errors list, and do not cause Load to // return an error. Clients may need to handle such errors before // proceeding with further analysis. The PrintErrors function is // provided for convenient display of all errors. func Load(cfg *Config, patterns ...string) ([]*Package, error) { … } // defaultDriver is a driver that implements go/packages' fallback behavior. // It will try to request to an external driver, if one exists. If there's // no external driver, or the driver returns a response with NotHandled set, // defaultDriver will fall back to the go list driver. func defaultDriver(cfg *Config, patterns ...string) (*driverResponse, error) { … } type Package … type Module … type ModuleError … func init() { … } type Error … type ErrorKind … const UnknownError … const ListError … const ParseError … const TypeError … func (err Error) Error() string { … } type flatPackage … // MarshalJSON returns the Package in its JSON form. // For the most part, the structure fields are written out unmodified, and // the type and syntax fields are skipped. // The imports are written out as just a map of path to package id. // The errors are written using a custom type that tries to preserve the // structure of error types we know about. // // This method exists to enable support for additional build systems. It is // not intended for use by clients of the API and we may change the format. func (p *Package) MarshalJSON() ([]byte, error) { … } // UnmarshalJSON reads in a Package from its JSON format. // See MarshalJSON for details about the format accepted. func (p *Package) UnmarshalJSON(b []byte) error { … } func (p *Package) String() string { … } type loaderPackage … type loader … type parseValue … func newLoader(cfg *Config) *loader { … } // refine connects the supplied packages into a graph and then adds type and // and syntax information as requested by the LoadMode. func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) { … } // loadRecursive loads the specified package and its dependencies, // recursively, in parallel, in topological order. // It is atomic and idempotent. // Precondition: ld.Mode&NeedTypes. func (ld *loader) loadRecursive(lpkg *loaderPackage) { … } // loadPackage loads the specified package. // It must be called only once per Package, // after immediate dependencies are loaded. // Precondition: ld.Mode & NeedTypes. func (ld *loader) loadPackage(lpkg *loaderPackage) { … } type importerFunc … func (f importerFunc) Import(path string) (*types.Package, error) { … } var ioLimit … func (ld *loader) parseFile(filename string) (*ast.File, error) { … } // parseFiles reads and parses the Go source files and returns the ASTs // of the ones that could be at least partially parsed, along with a // list of I/O and parse errors encountered. // // Because files are scanned in parallel, the token.Pos // positions of the resulting ast.Files are not ordered. // func (ld *loader) parseFiles(filenames []string) ([]*ast.File, []error) { … } // sameFile returns true if x and y have the same basename and denote // the same file. // func sameFile(x, y string) bool { … } // loadFromExportData returns type information for the specified // package, loading it from an export data file on the first request. func (ld *loader) loadFromExportData(lpkg *loaderPackage) (*types.Package, error) { … } // impliedLoadMode returns loadMode with its dependencies. func impliedLoadMode(loadMode LoadMode) LoadMode { … } func usesExportData(cfg *Config) bool { … }