Yes, it's conventional to use reflect.Type as a map key. In fact, you
should do that because not all types have different names, even if
they're in the same package.

For example: https://play.golang.org/p/Xqc8hkKPu4_v

On 18 August 2018 at 10:40, Christophe Meessen
<christophe.mees...@gmail.com> wrote:
> I need to index data by type and I have two options:
> - use a string as key and index the string returned by reflect.Type.Name()
> - use reflect.Type as key
>
> I have the impression that indexing by reflect.Type would be slightly more
> speed and space efficient, but I'm unsure if the relation between
> reflect.Type and reflect.Type.Name() is bijective.
>
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to