NOTE

Go Interfaces

Implicit interface satisfaction, dynamic type/value pairs, nil subtleties, and API design.

GoCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

A Go interface describes a method set; concrete types satisfy it implicitly. An interface value carries a dynamic type and value, so an interface containing a typed nil pointer is not itself a nil interface.

Define small interfaces at the point of use when they represent a meaningful capability. Accepting interfaces can decouple clients; returning concrete types often preserves more functionality. Avoid interface{}/any when static type information is available.

Loading helpful count