3 ms·
It was not until go1.8 that they added the warning to not use '=='. In go 1.7, it simply told you that == vs Equal had different semantics, see https://cs.opens
by TheDong 5y ago
It was not until go1.8 that they added the warning to not use '=='. In go 1.7, it simply told you that == vs Equal had different semantics, see https://cs.opensource.google/go/go/+/refs/tags/go1.7:src/time/time.go;l=67-71 https://cs.opensource.google/go/go/+/refs/tags/go1.7:src/tim...
There are many cases where you know that your times are in the same timezone, or you don't mind different timezones comparing as different, and so '==' used to work correctly quite often.
My program was clearly not broken in 1.7, when I followed the documentation "Equal ignores location, == uses location", and things worked well.
My program became counter to their documentation in 1.8. My program broke in 1.9.
I don't see how that is not a breaking change.
- Mawr 5y agoYeah, 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.