3 ms·
Is this really the case? Can you link to anything or an example on go.dev/play/ ? I can find a mention of "cmp.Equal" having that behavior, but that's just a t
by mappu 4y ago
Is this really the case? Can you link to anything or an example on go.dev/play/ ?
I can find a mention of "cmp.Equal" having that behavior, but that's just a third-party package panic.
- assbuttbuttass 4y agoIt's true, but you'd never really write code like this https://go.dev/play/p/r9NkQb6bQTx https://go.dev/play/p/r9NkQb6bQTx
- erik_seaberg 4y agoThe problem also affects structs that happen to have a private map or cache or callback anywhere within. https://go.dev/play/p/uP-vjpvuhku https://go.dev/play/p/uP-vjpvuhku
- preseinger 4y agoObviously `interface{}` values are not comparable?
- erik_seaberg 4y agoThe comparison is explicitly allowed in the language spec, there’s no warning for doing it, and it often works depending on the types. It’s a data-dependent runtime error, which is usually hard to guarantee test coverage for.