Sorry, I didn't include enough information, you are right, this is more about the type checker,
I have a call to conf.Check(pkg.path, fset, astFiles, &info) that does the typecheck gets the astFiles from the given package (a in this example) , but I didn't find a way to pass multiple packages to conf.Check If I mix files from diff packages in astFiles, I get an error from the type checker saying something like, expected package a but found b for file xyz.go conf is: conf := &types.Config{ Error: func(e error) { fmt.Println("failed to typecheck: ", e) os.Exit(1) }, Importer: importer.Default(), } Thanks On Monday, April 17, 2017 at 12:55:52 PM UTC-4, mhh...@gmail.com wrote: > > Can you clarify your expectation about ast ? > > in my very humble understanding, Obj is for type checker more than ast. > I re call when i worked with it, i had to hide it when i wanted to > visualize the tree > I even created a gist, > https://gist.github.com/mh-cbon/3ed5d9c39e9635cfed0f896000098133 > to use in place of https://golang.org/pkg/go/ast/#example_Print > > On Monday, April 17, 2017 at 3:45:23 PM UTC+2, Diego Medina wrote: >> >> Hi, >> >> I'm using go/ast (and token/types. etc) to parse a Go project, it all >> works well when my program only has one package, but there are times where >> I have code like this: >> >> file-a.go >> ========= >> package a >> >> ... >> >> selector := b.Selector(CompanyID) >> >> ... >> ======== >> >> and then >> >> file-b.go >> ======== >> package b >> >> .... >> >> func Selector(n string) string{ >> ... >> } >> ======== >> >> Simple, in package a I call a function from package b, the issue is that >> when I'm walking the ast for pacakge a, I reach selector as an *ast.Ident >> and then I check >> >> the .Obj value and it is nil. >> >> Is there a way to "fill in" this information? >> For now, the information I'm looking for is the Decl value, >> >> >> I tried using golang.org/x/tools/go/loader to solve this but it has the >> same issue, it doesn't "fill in" the missing information, it does give me a >> different way to access the declaration, but it also does a lot more work >> that I don't need and makes my too run slower. >> >> Hope I was clear. >> >> Thanks >> >> Diego >> >> >> -- 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. For more options, visit https://groups.google.com/d/optout.