implicit interface satisfaction

Go's rule that a type meets an interface just by having the right methods, with no implements declaration.

In more detail

The type's author never names the interface, so a consumer can define a small interface after the fact and existing types already fit it. This is what makes fakes for tests cheap. The compiler still checks the methods match wherever the value is used as that interface.

Example

func (Robot) Speak() string { return "ready" }  // Robot now satisfies Speaker

Related terms

Taught in

References