FWIW I believe there is enough subtlety here (small changes in the code
might trigger different compiler optimizations) that I wouldn't rely too
much on probing the compiler with different programs. Instead, I'd suggest
decompiling the binary and/or running it in a debugger, to check what the
actua
I encountered this tricky bug today. After going through all the playground
examples, I finally understood what was happening.
Similar to Jochen, I was including encoding.MarshalBinary() and
encoding.UnmarshalBinary() in the interface definition.
A question though. Why does this bug resolve by
What is really fantastical is that a==b prints false, even though the
pointers are actually the same. I am guessing some sort of optimization
effect is at play here.
https://go.dev/play/p/Dsqeh_aAXKT
type Foo struct {
}
func main() {
a := &Foo{}
b := &Foo{}
fmt.Printf("%t\n", *a == *b)
fmt.P