On Wed, 20 Jan 2021 at 11:04, Brian Candler <b.cand...@pobox.com> wrote:
> What do you make of this? > https://go2goplay.golang.org/p/gN-FK2kbYK5 > > Using interface values, it seems possible to bypass a declared constraint > that two arguments have the same type. > This code is misleading. By passing the value to `reflect.TypeOf`, you're losing the actual type of the value by converting it to interface{} first. Contrast your example with this, where we print the type of &a and &b instead of a and b, and you'll see that actually the types are identical. https://go2goplay.golang.org/p/CDmGFALAvCF This all seems fine to me, tbh. It does mean that you need to avoid invoking methods on freshly declared instances of generic types, but that's true for non-interface types too (the type might be a pointer). You can also pass nil pointer values as generic values, which can also panic when methods are invoked on them. cheers, rog. -- 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/CAJhgaciY1P0Sr_82scyEw2St5xWY1aXNQkATKwm%2BMrZy7akLXA%40mail.gmail.com.