A famous Chinese proverb attributed to Kong Fu Tse is, "Fathers father, sons son", meaning that the name of "father" is given to a man who raises children (fathers them), and the name of "son" is given to a boy/man who acts with filial duty (sons: as a verb). A name or role is properly granted only to those duties or functions it can perform; functions that are expected from the one bearing the name.
This is how we treat the implementation of Go interfaces implicitly, in that if a type has a function with the "Read(p []byte) (n int, err error)" specification it means it is capable of acting like a Reader, and therefore it IS a Reader. Likewise, we call a Writer that which can write (implements the Write(...) function).
A famous Chinese proverb attributed to Kong Fu Tse is, "Fathers father, sons son", meaning that the name of "father" is given to a man who raises children (fathers them), and the name of "son" is given to a boy/man who acts with filial duty (sons: as a verb). A name or role is properly granted only to those duties or functions it can perform; functions that are expected from the one bearing the name.
This is how we treat the implementation of Go interfaces implicitly, in that if a type has a function with the "Read(p []byte) (n int, err error)" specification it means it is capable of acting like a Reader, and therefore it IS a Reader. Likewise, we call a Writer that which can write (implements the Write(...) function).