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