Thanks for your explanation. Ian Lance Taylor <i...@golang.org> 于2023年6月4日周日 01:09写道:
> On Sat, Jun 3, 2023 at 10:05 AM 王谦铭 <wangqianming12...@gmail.com> wrote: > > > > If a pointer type implements a method in an interface, then its value > type variable cannot be assigned to the corresponding interface. > Conversely, if a value type implements a method in an interface, its > pointer type variable can be assigned to the corresponding interface. > > I want know why that can work? Just like the code. > > Please paste code as plain text or as a link to the Go playground. Thanks. > > In Go every value method--that is, every method with a value > receiver--is also valid for the pointer type. See > https://go.dev/ref/spec#Method_sets . > > 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJneERqEAMsJV-2FMoPx9F2cQGdtjFqJp8X57DyX0xW%3DN9Wx7w%40mail.gmail.com.