On Jun 14, 2016, at 2:43 PM, Aurélien Bombo <abom...@gmail.com> wrote:
> It's my understanding that the type checker considers named types identical 
> only if they're represented by the same pointer.
> Thus it makes sense for types.Identical and typeutil.Hasher.Hash to return 
> incoherent results for say,
> type a.MyInt int and type b.MyInt int in packages a and b respectively.
> 
> Am I correct in assuming these are the only way to check if two named types 
> are identical, or did I forget something?

You can implement a custom type comparison using methods like 
reflect.Type.Kind(), recursively investigating structs and methods and so on, 
if you want a structural-equality comparison.

My gut feeling is that there's usually a better way to architect things than 
doing runtime type inspection, though (obviously some things do benefit from 
it).



-- 
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