It is very confusing that equality in JavaScript is not transitive: https://imgur.com/5pFXFbR.
Apparently equality in Go is no longer transitive either...
Apparently equality in Go is no longer transitive either...
There's a lot of rules in Go for what == does, and maybe there's something non-transitive in there, but I'd definitely need to see someone prove it on https://play.golang.org/ to be sure. Offhand I can't think of how to make one.
var b *bytes.Buffer
var r io.Reader = b
fmt.Printf("r == nil: %v; b == nil: %v; r == b: %v\n", r == nil, b == nil, r == b)
r == nil: false; b == nil: true; r == b: trueIf it's acting as a proxy it's confusing the specific way that some things get proxied and other things don't.
b2, ok := r.(*bytes.Buffer) equal := ok && b2 == b
There are 2 types of equality in JS, shallow (==) and 'strict' (===). It's fine because JS is a dynamic, weakly typed language.
Go isn't supposed to be.