On Fri, 2020-08-21 at 21:51 -0700, Ian Lance Taylor wrote: > > > Thanks, Ian. > > > > No that doesn't work. For example with type byte, you get back the > > byte > > name. > > > > https://play.golang.org/p/PPjHBotsIsw > > The underlying type of byte is indeed byte. What are you hoping for? > > Ian
I'm hoping for a resolution of the type to its base unaliased type. The types.Type of a "byte" is &types.Basic{kind: types.Uint8, info: types.IsInteger|types.IsUnsigned, name: "byte"} while the type for "uint8" (obtained either from syntax or from types.Typ[types.Uint8], or types.Typ[types.Byte]) is the same, but with name = "uint8". The same situation is true for rune/int32. https://play.golang.org/p/cbbU7-qzwxQ I would like to resolve all types that are aliases to a single string representation. Paul's code at https://play.golang.org/p/MHjgBvbOG__G shows that for other cases .Underlying() is not needed, it resolves to the original type. It it's just uint8/byte and int32/rune, I can special case them and do a looking into types.Typ with the type's Kind. 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/090030433605a38cbec52370113674d32218797a.camel%40kortschak.io.