Hello, I'm working on a DAO adapter layer helper called Proteus (https://github.com/jonbodner/proteus), and ran into an interesting quirk in what Go considers equivalent interfaces. I recreated a simplified version of the issue is at https://play.golang.org/p/BS3-bUKtO9 .
The code that I linked does not compile, with the error: V does not implement CalcB (wrong type for Calculate method) have Calculate(int) ResultA want Calculate(int) ResultB ResultA and ResultB are identical interfaces; both define a single method Result that takes in no parameters and return an int. However, if I put in a wrapper around V, I can get it to work: https://play.golang.org/p/XUoZwsBaFn What I don't understand is that the wrapper doesn't do any casting of ResultA to ResultB, and that's OK in this situation. But the Go compiler can't figure out that ResultA and ResultB are identical without that wrapper. Why is that? Why does the compiler fail the first case and pass the second one? Thanks, Jon -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.