Documentation ¶
Overview ¶
Package gcimporter implements Import for gc-generated object files. Importing this package installs Import as go/types.DefaultImport.
Index ¶
- func FindExportData(r *bufio.Reader) (err error)
- func FindPkg(ctxt *build.Context, path, srcDir string) (filename, id string)
- func Import(ctxt *build.Context, packages map[string]*types.Package, path string) (pkg *types.Package, err error)
- func ImportData(packages map[string]*types.Package, filename, id string, data io.Reader) (pkg *types.Package, err error)
- func IsNotFound(err error) bool
- type NotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindExportData ¶
FindExportData positions the reader r at the beginning of the export data section of an underlying GC-created object/archive file by reading from it. The reader must be positioned at the start of the file before calling this function.
func FindPkg ¶
FindPkg returns the filename and unique package id for an import path based on package information provided by build.Import (using the build.Default build.Context). If no file was found, an empty filename is returned.
func Import ¶
func Import(ctxt *build.Context, packages map[string]*types.Package, path string) (pkg *types.Package, err error)
Import imports a gc-generated package given its import path, adds the corresponding package object to the packages map, and returns the object. Local import paths are interpreted relative to the current working directory. The packages map must contains all packages already imported.
If the gc-generated package cannot be found a *NotFoundError is returned.
func ImportData ¶
func ImportData(packages map[string]*types.Package, filename, id string, data io.Reader) (pkg *types.Package, err error)
ImportData imports a package by reading the gc-generated export data, adds the corresponding package object to the packages map indexed by id, and returns the object.
The packages map must contains all packages already imported. The data reader position must be the beginning of the export data section. The filename is only used in error messages.
If packages[id] contains the completely imported package, that package can be used directly, and there is no need to call this function (but there is also no harm but for extra time used).
Types ¶
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
A NotFoundError is returned by Import when the package file cannot be found.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) ID ¶
func (e *NotFoundError) ID() string
ID returns the package id created by FinkPkg for the missing package.
func (*NotFoundError) Path ¶
func (e *NotFoundError) Path() string
Path returns the path argument passed to Import and FindPkg.
func (*NotFoundError) String ¶
func (e *NotFoundError) String() string
String returns e formatted as 'NotFoundError{id: %s path: %s}' for debugging.