Description
I really like the new packages.LoadMode
bits that were introduced to fix #29429, thanks! I'm using go/packages for a utility to gather example functions in the Go CDK. Part of what this tool does is to determine which imports an example uses, which I'm doing by walking the AST of the example function body and using type information to see whether an identifier is a package name. I've been using a LoadMode
of NeedName | NeedFiles | NeedTypes | NeedSyntax | NeedTypesInfo
.
However, I discovered this check doesn't work if the package is not in the stdlib or in the set of directly matched packages. In an upcoming change, I will add NeedImports | NeedDeps
, but this results in a 10x slowdown. I assume this is because it is syntax + type-checking the dependencies, which is not what I need. I really only need NeedName
for dependencies, but I can't see a way of specifying that. Similar to #28740, I would like to specify different behavior for dependencies versus directly referenced packages.
/cc @matloob @ianthehat