Hello,
I am trying to use go generate with an embedded type, which is imported from another package. But, I am not sure how to walk further the AST.
package "one"
type Entity struct {
Id string
}
//-------------------
package "two"
import "one"
type Person struct {
one.Entity
Name string
}
func buildField(expr ast.Expr, name string) error {
switch ident := expr.(type) {
case *ast.Ident:
...
case *ast.SelectorExpr:
if pkgIdent, ok := ident.X.(*ast.Ident); ok {
// how to get struct entity and its fields (Id) from here ??
}
}
}
one I get an external package and the type info as shown above, how to get the fields in Entity type which is in another package?
any pointers to help me proceed is appreciated.
thanks.
bsr