// Import implements types.Importer.Import.
Import implements types.Importer.Import.
// Import implements types . Importer . Import .
func (i *importer) Import(path string) (*types.Package, error) {
	if path == "unsafe" {
		return types.Unsafe, nil
	}
	if i.callback != nil {
		if err := i.callback(path); err != nil {
			i.lastErr = err
			return nil, err
		}
	}
	realPath, ok := i.ImportMap[path]
	var (
		rc  io.ReadCloser
		err error
	)
	if !ok {
		rc, err = findStdPkg(i.GOOS, i.GOARCH, path)
	} else {
		rc, err = os.Open(realPath)
	}
	if err != nil {
		i.lastErr = err
		return nil, err
	}
	defer rc.Close()
	r, err := gcexportdata.NewReader(rc)
	if err != nil {
		return nil, err
	}
	return gcexportdata.Read(r, i.fset, i.cache, path)
}
func ( i * importer ) Import ( path string ) ( * types . Package , error ) { if path == " " { return types . Unsafe , nil } if i . callback != nil { if err := i . callback ( path ) ; err != nil { i . lastErr = err return nil , err } } realPath , ok := i . ImportMap [ path ] var ( rc io . ReadCloser err error ) if ! ok { rc , err = findStdPkg ( i . GOOS , i . GOARCH , path ) } else { rc , err = os . Open ( realPath ) } if err != nil { i . lastErr = err return nil , err } defer rc . Close ( ) r , err := gcexportdata . NewReader ( rc ) if err != nil { return nil , err } return gcexportdata . Read ( r , i . fset , i . cache , path ) }
Import implements types.Importer.Import.
Import implements types . Importer . Import .
// Special case: go/types has pre-defined type information for // unsafe. We ensure that this package is correct, in case any // analyzers are specifically looking for this. // Call the internal callback. This is used to resolve loading order // for the standard library. See checkStdlib. // Actually load the data. // Not found in the import path. Attempt to find the package // via the standard library. // Open the file. // Load all exported data.