I would like to parse the following and determine that "have.Bar" is a 
"Bar" from package "some/package/i/dont/have", with the caveat that I don't 
have access to that package.

package foo

import "some/package/i/dont/have"

type Foo struct {
    have.Bar
}

In other words, the ideal function (depending implicitly on the entire 
file) for me would be:

func GetSource(id *ast.Ident) (fullPackage string, err error)

var Bar *ast.Ident  // Gotten from an ast walk
GetSource(Bar) == "some/package/i/dont/have", nil


As suggested at 
https://github.com/golang/example/tree/master/gotypes#identifier-resolution, 
I am trying to use the types package to map each identifier to an object. 
However, I don't have access to "some/package/i/dont/have" so I am getting 
an import error (see https://play.golang.org/p/91We3222_Yx), I assume 
because any actual typechecking would need to go into the package to get 
the underlying type.

Any recommendations on how I can implement this "shallow" type retrieval 
without access to imports?

-- 
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.

Reply via email to