After reading a related question about using slices in maps, I became curious about equality in Go.
I know it\'s possible to override the equals method of a
There's no standard in Go language itself, yet (go 1.13).
However, comparison utilities could provide their own way to support it.
Function cmp.Equal (from google/go-cmp/cmp) supports definition of custom type comparator via definition of a Equal method:
• If the values have an Equal method of the form
"(T) Equal(T) bool"or"(T) Equal(I) bool"whereTis assignable toI, then use the result ofx.Equal(y)even ifxoryis nil. Otherwise, no such method exists and evaluation proceeds to the next rule.