We break down what “comparable” (
comparable) means in Go: why you can compare a struct via
== only when all its fields are comparable, what breaks comparability (for example,
slice,
map,
func), why
interface fields are tricky (a
panic at runtime is possible), how pointer comparisons (
*
T) can be interpreted differently, and why comparability is directly tied to whether a value can be used as a key in a
map.