AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
What's the Deal With Comparative Types in Go?
In the Go spec, there's this idea of comparable types and then types that are not comparable. A comparable type is like if you have two strings, you can say string X equals string Y or string X does not equal string Y. There are things that are not similar in Go such as slices being different areas in memory. You're just not allowed to compare slices to each other. That's the only legal comparison you can make. And so for interface types, this gets a little bit weird. If you want to say X equal to Y and X and Y are both some interface type, you can do that even if the concrete type underneath the interface is something that wouldn't normally be