Skip to content

Interfaces: resources

Level: 201 · anyone who wants the sources behind this chapter, by section

One line: The spec sections that define method sets, embedding, interface satisfaction and type assertions; the runtime and FAQ pages behind the two-word layout and the typed nil; the shelf books by chapter and section; three talks; and the advice that no longer holds.

Primary sources

Books

  • Alan A. A. Donovan and Brian W. Kernighan, The Go Programming Language (Addison-Wesley, 2015) — chapter 6, "Methods": 6.2 "Methods with a Pointer Receiver", 6.3 "Composing Types by Struct Embedding", 6.4 "Method Values and Expressions"; chapter 7, "Interfaces": 7.3 "Interface Satisfaction", 7.5 "Interface Values" (with the caveat "An Interface Containing a Nil Pointer Is Non-Nil"), 7.6 "Sorting with sort.Interface", 7.10 "Type Assertions", 7.12 "Querying Behaviors with Interface Type Assertions", 7.13 "Type Switches". Still the most precise book treatment of method sets and interface values.
  • Jon Bodner, Learning Go, 2nd ed. (O'Reilly, 2024) — chapter 7, "Types, Methods, and Interfaces": "Pointer Receivers and Value Receivers", "Code Your Methods for nil Instances", "Use Embedding for Composition", "Embedding Is Not Inheritance", "Interfaces Are Type-Safe Duck Typing", "Embedding and Interfaces", "Accept Interfaces, Return Structs", "Interfaces and nil", "Interfaces Are Comparable", "The Empty Interface Says Nothing", "Type Assertions and Type Switches", "Use Type Assertions and Type Switches Sparingly".
  • Adam Freeman, Pro Go (Apress, 2022) — chapter 11, "Using Methods and Interfaces": "Understanding Pointer and Value Receivers", "Understanding the Effect of Pointer Method Receivers", "Comparing Interface Values", "Performing Type Assertions", "Switching on Dynamic Types", "Using the Empty Interface"; chapter 13, "Type and Interface Composition": "Composing Types", "Understanding When Promotion Cannot Be Performed", "Using Composition to Implement Interfaces", "Composing Interfaces".
  • Go in Practice, 2nd ed. (Manning, 2025) — chapter 3, "Structs, interfaces, and generics": 3.3 "Extending functionality with interfaces"; chapter 13, on reflection: 13.1.2 "Discovering whether a value implements an interface" — the reflect view of the method-set check.
  • Miki Tebeka, Effective Go Recipes (Pragmatic, 2024) — chapter 7, "Working with Structs, Methods, and Interfaces": Recipe 37, "Using Ad Hoc Interfaces", and Recipe 38, "Wrapping the http.ResponseWriter Interface" — the second is embedding an interface to override one method, the shape of this chapter's sort.Reverse kata.

Not on the shelf

  • Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them (Manning, 2022) — 100go.co ↗; its mistakes on interface pollution, returning interfaces, and the nil receiver in an interface cover this chapter's ground.
  • Bartłomiej Płotka, Efficient Go (O'Reilly, 2022) — the publisher's page ↗; the allocation cost of interfaces among its optimisations.

Talks and videos

Read with care

  • Pre-1.18 explanations of "the empty interface" as interface{} are right but dated: any is its alias since Go 1.18, and interfaces have had a second life as type sets since then — an interface with a type union can be a constraint only, not a variable's type (A type parameter needs a constraint).
  • Advice that interface method calls are "slow" in the abstract. The itab makes a call one indirection; what costs is the boxing on the way in, which is zero for pointers and small integers and one allocation for most other values — measured, not assumed, in An interface is two words.
  • Claims that go vet catches the typed-nil error. It does not, at go1.25; the vet page runs it and lists what does.
  • Descriptions of embedding as "inheritance" or of promoted methods as "overridable". Embedding is not inheritance prints the call that inheritance would have dispatched the other way.
  • Older tutorials that store a sync.Mutex in a struct and pass the struct by value, or give such a struct value-receiver methods; go vet's copylocks reports every such copy, and the vet page shows the message.

Checked 2026-09-23.