I think I'm now starting to get the hang of traversing around and looking up type info as needed now.
Are there any higher level libraries around which make navigating the ASTs easier? I'm finding I need to do a lot of conditional casts, which doesn't help the signal:noise ratio of my functions On Sunday, 27 September 2020 at 22:28:03 UTC+1 kortschak wrote: > On Sun, 2020-09-27 at 11:45 -0700, Glen Mailer wrote: > > > > Hello! > > > > I'm playing about with some go tooling, and I wanted to parse a > > package with type information to inspect it and derive some insights > > from the data. > > > > I found the packages tool - > > https://godoc.org/golang.org/x/tools/go/packages - which on the > > surface appears to be exactly what I wanted. > > > > However the output of this on a package (with all flags enabled) > > appears to be a slice of *ast.File nodes - which contain unresolved > > references, and a types.Package - from which I can inspect scopes. > > > > I can't seem to find a way to inspect the resolved AST along with > > types - am I missing something or do I need to do more legwork > > myself? > > > > Cheers > > Glen > > > The TypesInfo field of packages.Package holds the information you want. > https://godoc.org/golang.org/x/tools/go/packages#Package > > > -- 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/52df6136-8ca2-48b3-b222-17f3d8be8075n%40googlegroups.com.