On Sat, 2020-08-15 at 21:44 -0700, Ian Lance Taylor wrote: > On Sat, Aug 15, 2020 at 3:45 PM 'Dan Kortschak' via golang-nuts > <golang-nuts@googlegroups.com> wrote: > > > > I would like to be able to obtain the original type for an alias > > given > > a source input. I can see in "go/types" that it's possible to know > > whether a named type is an alias by `typ.Obj().IsAlias()`, but I > > cannot > > see how to obtain the actual original type unless it is an alias > > for a > > basic type. > > > > Can someone point me to a way to get this information? From the > > source > > it looks something like > > `typ.Obj().Type().(*types.Named).Obj().Type()`. > > Is this correct assuming that the original type is a named type? > > I haven't tested it but I *think* you can just write > typ.Underlying(). > > Ian
Thanks, Ian. No that doesn't work. For example with type byte, you get back the byte name. https://play.golang.org/p/PPjHBotsIsw Dan -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d3f6c5b7a76f7ea2db93f34fa87917651dcc7ad5.camel%40kortschak.io.