How do method sets work in Go, and why can a value type sometimes fail to satisfy an interface that a pointer type satisfies?
Last updated
A method set is the methods callable on a type.
Thas only value-receiver methods, while*Thas both value- and pointer-receiver methods.If an interface method uses a pointer receiver, only
*Tsatisfies it, because a value stored in an interface isn't addressable.Go auto-takes the address when calling pointer methods on addressable variables, which hides the rule until you assign to an interface.