Hi Ian, The issue you pointed at is exactly what I'd like to see.
In my case, I'm providing an interface that matches what's in database/sql without creating an explicit dependency on database/sql (for cases when non-sql databases, or non-databases are used for data storage). I think this is a pretty common pattern in Go, writing code that consumes interfaces defined within the same project, even if the methods are identical to those on an interface in a third-party package. What would I need to do to get more consideration for including #16209 in Go 1.8? Thanks, Jon On Sunday, July 3, 2016 at 11:29:32 PM UTC-4, Ian Lance Taylor wrote: > > On Sun, Jul 3, 2016 at 12:27 PM, Jon Bodner <j...@bodnerfamily.com > <javascript:>> wrote: > > > > 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? > > ResultA and ResultB are assignable but not identical. > > https://golang.org/ref/spec#Type_identity > https://golang.org/ref/spec#Assignability > > For the specific case of interface types, you may be interested in > https://golang.org/issue/16209 . > > Ian > -- 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.