Re: [go-nuts] What's the recommended way to determine if a type.Type is exported?

2017-04-29 Thread 'Axel Wagner' via golang-nuts
Ah sorry, I apparently didn't pay close attention then. The correct way is to type-assert to *types.Named and then use it's Obj() method, I guess. :) BTW: It's not "casting", but "type-asserting". "casting" (go calls it "converting") is, when you have something with concrete type T1 and convert

Re: [go-nuts] What's the recommended way to determine if a type.Type is exported?

2017-04-29 Thread me
What exactly would you cast to *types.TypeName, btw? Looks like *types.TypeName is not a types.Type (missing Underlying() method). On Sunday, April 23, 2017 at 11:11:13 PM UTC-7, Axel Wagner wrote: > > I'd say, probably type-asserting to a *types.TypeName >

Re: [go-nuts] What's the recommended way to determine if a type.Type is exported?

2017-04-24 Thread Kevin Conway
Alternatively, if you are walking an AST and only interested in the exported names then you can use https://golang.org/pkg/go/ast/#PackageExports . It will filter your tree to only elements that are exported before you begin traversal. As to your specific case of determining if a type used in a

Re: [go-nuts] What's the recommended way to determine if a type.Type is exported?

2017-04-24 Thread Tejas Manohar
Agreed! I ended up casting to types.NamedType (or pointer then elem())... I'll try your method too! On Sun, Apr 23, 2017 at 11:11 PM Axel Wagner wrote: > I'd say, probably type-asserting to a *types.TypeName > and then