October 2015
Beginner to intermediate
400 pages
14h 44m
English
Interfaces are used in two distinct styles.
In the first style, exemplified by io.Reader,
io.Writer, fmt.Stringer, sort.Interface,
http.Handler, and error,
an interface’s methods express the similarities of
the concrete types that satisfy the interface but hide the
representation details and intrinsic operations of those concrete
types.
The emphasis is on the methods, not on the concrete types.
The second style exploits the ability of an interface value to hold values of a variety of concrete types and considers the interface to be the union of those types. Type assertions are used to discriminate among these types dynamically and treat each case differently. In this style, the emphasis is on the concrete types that satisfy ...