예제 #1
0
파일: main.go 프로젝트: kisielk/uses
func NewContext() *Context {
	importer := importer.NewImporter()
	ctx := &Context{
		allImports: importer.Imports,
		context: types.Context{
			Import: importer.Import,
		},
	}

	return ctx
}
예제 #2
0
파일: errcheck.go 프로젝트: j6n/errcheck
// typeCheck creates a typedPackage from a package_
func typeCheck(p package_) (typedPackage, error) {
	tp := typedPackage{
		package_:  p,
		callTypes: make(map[ast.Expr]types.Type),
		identObjs: make(map[*ast.Ident]types.Object),
	}

	info := types.Info{
		Types:   tp.callTypes,
		Objects: tp.identObjs,
	}
	context := types.Config{Import: importer.NewImporter().Import}

	_, err := context.Check(p.path, p.fset, p.astFiles, &info)
	return tp, err
}