Esempio n. 1
0
// importType returns the type denoted by the qualified identifier
// path.name, and adds the respective package to the imports map
// as a side effect.
func importType(path, name string) types.Type {
	pkg, err := types.DefaultImport(imports, path)
	if err != nil {
		warnf("import failed: %v", err)
		return nil
	}
	if obj, ok := pkg.Scope().Lookup(name).(*types.TypeName); ok {
		return obj.Type()
	}
	warnf("invalid type name %q", name)
	return nil
}
Esempio n. 2
0
// srcImporter implements the ast.Importer signature.
func srcImporter(imports map[string]*types.Package, path string) (pkg *types.Package, err error) {
	return types.DefaultImport(imports, path)
}