Section 3 of 11

Implicit interfaces

The biggest idea in Go. Interfaces are declared by the consumer, not the producer.

There is no `implements` keyword. A type satisfies an interface simply by having the right methods. The consequence is that interfaces get declared where they are used, stay tiny, and can be retrofitted onto types you do not own.

Nobody says "implements"

go.dev playground

Try it: Delete the Speak method from Dog and read the error — that is what a failed implicit satisfaction looks like.

The stdlib lives on this. io.Writer is one method, and because os.Stdout, a network connection, a file, and a bytes.Buffer all have it, every one of them is a drop-in for the others.

One method, and everything composes

go.dev playground

Try it: Swap os.Stdout for &buf on the greet call and the same function writes into memory instead of the terminal.