3 ms·
Yeah, you're right. I didn't think to check previous versions. It seems to me like a flaw in the language that "==" can compare unexported struct fields. Look
by Mawr 5y ago
Yeah, you're right. I didn't think to check previous versions.
It seems to me like a flaw in the language that "==" can compare unexported struct fields.
Looks like it's possible to disallow comparing structs with "==" at compile time: https://go.dev/play/p/BfM6sDxlTq9 https://go.dev/play/p/BfM6sDxlTq9. Not ideal, but better than nothing I suppose.
- Mawr 5y ago> Looks like it's possible to disallow comparing structs with "==" at compile time. But of course, then such structs cannot be used as map keys: https://go.dev/play/p/JXzqHPInJ-G https://go.dev/play/p/JXzqHPInJ-G.