On Sat, Jun 3, 2023 at 10:05 AM 王谦铭 <
wangqian...@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