Question for Wolfram or any other Go experts. Here's a code snippet that caused a problem for me today:
Code:
n, addr, err := conn.ReadFrom(buf)
...
if addr != sock.addr {
}
These variables are of the type net.Addr, which is an interface. I assumed this would perform struct-level equality, and I was wrong; it did pointer comparison, and even though the addresses held identical data, it executed the code in the if.
So, uh, what's the right way to do this? This kinda led me down a rabbit hole of how interfaces, despite being the same type on the surface, can hold either a struct (if they did in this case, my code above would have worked as I expected) OR a pointer, and behave differently as a result. In C++ you at least know what type of object you're dealing with (if you have pointers, you can dereference them to compare data equality), and I'm not sure how to deal with this uncertainty in Go.