Slow type checker speed

75 views
Skip to first unread message

Darshit Doshi

unread,
Jun 24, 2020, 12:05:39 PM6/24/20
to golang-nuts
Hi, I'm working on some codegen logic which uses a file's AST to generate some functions. I want to find the zero values of certain identifier types, and to do this, I need underlying types of these indentifiers. 
So I use go's type checker, however it takes a very long time for it to completely type-check a package (a comparatively large package as compared to other packages in the source code). The whole source code takes about 30s to build but about 1 minute to type-check a large package.

I'm using the importer which loads the program from source:

conf := types.Config{Importer: importer.ForCompiler(fset, "source", nil)}
info := &types.Info{
    Uses: make(map[*ast.Ident]types.Object),
}
_, err := conf.Check(pkgPath, fset, fileAST, info)

Seems like I'm missing something here. Any help would be great!
Thanks
Reply all
Reply to author
Forward
0 new messages