In the description of context.WithValue(), we have:

The provided key must be comparable and should not be of type string
or any other built-in type to avoid collisions between packages using
context. Users of WithValue should define their own types for keys. To
avoid allocating when assigning to an interface{}, context keys often
have concrete type struct{}.

I am wondering if someone can explain what exactly comparable means here?

In other languages and Go
(https://golang.org/ref/spec#Comparison_operators), comparable usually
means being able to compare two values for equality/greater/lesser.

Thanks,
Amit.

-- 
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/CANODV3kUmtJvG9Lfys_HXfedwnm54neA6uub6cY1aiz%2B9w5DUA%40mail.gmail.com.

Reply via email to