No, they are not. They are both defined types and as such, are not identical <https://golang.org/ref/spec#Type_identity>. To repeat, this is answered in the FAQ <https://golang.org/doc/faq#covariant_types>.
On Mon, May 24, 2021 at 11:06 PM Amnon <amno...@gmail.com> wrote: > yes, but surely the return types are equivalent? > > On Monday, 24 May 2021 at 17:08:07 UTC+1 asv...@gmail.com wrote: > >> >> Interfaces are not equal: "m2() aer" and "m2() ber" has different return >> type. Even compiler told you about it. >> On Monday, May 24, 2021 at 9:20:51 AM UTC+3 Amnon wrote: >> >>> See https://play.golang.org/p/5x9JrD55WKc >>> >>> The interfaces aer and ber look equivalent. >>> Both contain a function which returns nothing called m1 >>> and a function which returns another an instance of the interface m2. >>> >>> If we comment out m2, then the code will compile. >>> But otherwise we get an error: >>> >>> ./prog.go:14:5: cannot use a (type aer) as type ber in argument to bar: >>> aer does not implement ber (wrong type for m2 method) have m2() aer want >>> m2() ber >>> >>> even though aer and ber should be equivalent! >>> >>> package main >>> >>> type aer interface { >>> m1() >>> m2() aer >>> } >>> >>> type ber interface { >>> m1() >>> m2() ber >>> } >>> >>> func Foo(a aer) { >>> bar(a) >>> } >>> >>> func bar(b ber) { >>> } >>> >>> func main() { >>> } >>> >>> -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/dcac0e8a-9dbd-4ac1-9670-b78243c9d2d1n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/dcac0e8a-9dbd-4ac1-9670-b78243c9d2d1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfF9H%3D2iYG8Bd_A%2Bk3EzX1ppuo3DmhXw_wMua-o9faMWLw%40mail.gmail.com.