I am trying to analyze a large application using Go's static analysis 
support. I am using the "packages" 
<https://godoc.org/golang.org/x/tools/go/packages> package to load all 
application packages using the Load 
<https://godoc.org/golang.org/x/tools/go/packages#Load> function.  
Unfortunately the application is really big and the list of patterns that 
the Load function takes the second parameter is really long. This causes a 
problem on Mac OS as in this case it leads to the "argument list too long" 
error popping up after the Load function is called. The reason for it is 
that internally, the Load function executes "go list" command passing it 
the list of patterns as arguments, which leads to exceeding the limit 
established by Mac OS (which, as far as I can tell, cannot be changed).

The usual workaround for this problem is to split the argument list and 
apply a given function incrementally to each list fragment - in this case 
it would mean calling the Load function multiple times with a different 
subset of the patterns list at each invocation. This, however, does not 
quite work, as it messes up the SSA representation that I need to generate 
afterwards using AllPackages 
<https://godoc.org/golang.org/x/tools/go/ssa/ssautil#AllPackages> function 
from the "ssautil" <https://godoc.org/golang.org/x/tools/go/ssa/ssautil> 
package. The AllPackages function constructs a program 
<https://godoc.org/golang.org/x/tools/go/ssa#Program> that contains a "file 
set" <https://godoc.org/go/token#FileSet> containing all files constituting 
the program. As far as I can tell, the only way to access this file set 
during analysis is via the program itself. And this is the gist of the 
problem, incremental application of the Load function creates a "file set" 
per increment, and the resulting program during SSA construction will 
assign only one to the program, making the remaining ones inaccessible 
during analysis.

I can't think of a viable workaround here (one that I considered is trying 
to use the loader <https://godoc.org/golang.org/x/tools/go/loader> package 
but it's deprecated and does not support modules), but perhaps someone will 
have an advice on how to proceed here...

Adam

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3dad4625-1b92-4438-b753-c63153c15848%40googlegroups.com.

Reply via email to