Curriculum Idioms & ecosystem The small-interface idiom exercise 1 · mcq
The small-interface idiom
The Go community phrase is: "accept interfaces, return structs." Pick the statement that best explains WHY. TypeScript: structural typing makes this less of a sharp distinction; you can return a wide type and callers don't care. Go's nominal-yet-implicit interface satisfaction rewards the rule more strongly.
TypeScript reference
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.