// Find returns the name of an object (.o) or archive (.a) file // containing type information for the specified import path, // using the workspace layout conventions of go/build. // If no file was found, an empty filename is returned. // // A relative srcDir is interpreted relative to the current working directory. // // Find also returns the package's resolved (canonical) import path, // reflecting the effects of srcDir and vendoring on importPath. func Find(importPath, srcDir string) (filename, path string) { … } // NewReader returns a reader for the export data section of an object // (.o) or archive (.a) file read from r. The new reader may provide // additional trailing data beyond the end of the export data. func NewReader(r io.Reader) (io.Reader, error) { … } // Read reads export data from in, decodes it, and returns type // information for the package. // The package name is specified by path. // File position information is added to fset. // // Read may inspect and add to the imports map to ensure that references // within the export data to other packages are consistent. The caller // must ensure that imports[path] does not exist, or exists but is // incomplete (see types.Package.Complete), and Read inserts the // resulting package into this map entry. // // On return, the state of the reader is undefined. func Read(in io.Reader, fset *token.FileSet, imports map[string]*types.Package, path string) (*types.Package, error) { … } // Write writes encoded type information for the specified package to out. // The FileSet provides file position information for named objects. func Write(out io.Writer, fset *token.FileSet, pkg *types.Package) error { … } // ReadBundle reads an export bundle from in, decodes it, and returns type // information for the packages. // File position information is added to fset. // // ReadBundle may inspect and add to the imports map to ensure that references // within the export bundle to other packages are consistent. // // On return, the state of the reader is undefined. // // Experimental: This API is experimental and may change in the future. func ReadBundle(in io.Reader, fset *token.FileSet, imports map[string]*types.Package) ([]*types.Package, error) { … } // WriteBundle writes encoded type information for the specified packages to out. // The FileSet provides file position information for named objects. // // Experimental: This API is experimental and may change in the future. func WriteBundle(out io.Writer, fset *token.FileSet, pkgs []*types.Package) error { … }