Skip to content
Randall O'Reilly edited this page Dec 31, 2018 · 2 revisions

Go in GoPi

The Go-specific code is in langs/golang package. golang.go has the Lang interface.

  • FileState .Syms has 1 symbol, the package, top-level elements (var, type, const, func, etc) are in Children

  • FileState .ExtSyms has one entry for each import package (see GoLang ParseFile() method)

  • Cache data for a given package is generated by GoLang ParseDir method, which loads cached data and uses that if it is more recent than the most recent file modification in target directory. If it needs to regenerate, it goes through each file in turn and runs ParseAll, and then aggregates the resulting package-level .Syms data into an overall master. It does not drill down into any of the imports for that package -- those references are all left as-is to be resolved later. It does attempt to resolve all types for symbols within the package.

  • The types.go file has good examples of how to process the Parser Ast output to fill in the syms.Type information.

The cmd/pi command allows you to run the parser on a directory (and its subdirectories, using the -r option), and see any error messages it has. If you do make test it will process the entire Go std library (on a mac using 1.11.3 installed using homebrew -- you can see in the Makefile how to run it otherwise) and compare the results against the current standard output -- this is the primary form of testing at this point (not exactly unit testing, but using gide provides a good constant test as well).

Clone this wiki locally