Hi,

Based on the documentation:

"The map key can be any type that is comparable."
"Struct values are comparable if all their fields are comparable. Two 
struct values are equal if their corresponding non-blank fields are equal."
"Interface values are comparable. Two interface values are equal if they 
have identical dynamic types and equal dynamic values or if both have value 
nil."

My understanding is that I can use an structure like this as a key for a map

type dialer interface {
    dial()
}

type key struct {
    id     string
    number int
    dialer      dialer
}

It also seems to work fine https://go.dev/play/p/hKQfx-JH5WP

But I'm wondering if I'm missing something or are there some corner cases I 
should take into account before doing this ...  or if this is not 
recommended at all

Thanks,

-- 
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/97b7368e-d276-40ab-afa3-f8a7868fd9ean%40googlegroups.com.

Reply via email to