https://golang.org/pkg/go/types/#Type

Is there a helper function to determine whether a *types.Type* is exported? 
It seems like I can do some string parsing like

t := something.Type()
parts := strings.Split(t.String(), ".") // go/ast.Node => ["go/ast", "Node"]
ident := parts[len(parts)-1] // "Node"
exported := strings.IsUpper(ident[0])

but I imagine there's a simpler, more robust way. The end goal is to find 
out whether a type of a method argument is exported-- e.g.
namedType := obj.Type().(*types.Named)
method := namedType.Method(0)
signature := method.Type().(*types.Signature)
signature.Params().At(0).Type() // is this exported?

And, for some context, all of this is from walking go/ast

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