typeover
curriculum

Curriculum Idioms & ecosystem The small-interface idiom exercise 2 · mcq

The small-interface idiom

fmt.Stringer is the most common one-method interface in Go. Pick its definition.

TypeScript reference
Pick the idiomatic Go translation

About this theme

io.Reader { Read(p []byte) (n int, err error) }. One method. Go interfaces are typically tiny because implicit satisfaction rewards it — small interfaces are easy to satisfy accidentally, which is good. The community phrase: "accept interfaces, return structs." Funcs take the smallest interface they need.