Structural typing
Go interfaces are satisfied implicitly:
type Sayer interface {
Say() string
}
Any type with a Say() string method is a Sayer, even if it never mentions Sayer. This keeps code decoupled and easy to extend.
Interface composition
Combine interfaces:
type Reader interface {
Read([]byte) (int, error)
}
type Writable interface {
Reader
Write([]byte) (int, error)
}
Writable embeds Reader, so anything that is Writable is also a Reader.