I think you were unlucky with your choice of type to experiment with. My understanding is that byte is special cased, despite being an alias:
https://github.com/golang/go/blob/13e41bcde8c788224f4896503b56d42614e0bf97/src/go/types/universe.go#L25 Consider instead https://play.golang.org/p/MHjgBvbOG__G On Sat, 22 Aug 2020 at 05:16, 'Dan Kortschak' via golang-nuts <golang-nuts@googlegroups.com> wrote: > > 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. -- 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/CACoUkn5c%3D5CpNN0uUJp6QJp5dFsSg-wtV_AK4MixTMVmnYY86w%40mail.gmail.com.