The power of single-method interfaces in Go

This is an excellent example of how the Go language facilitates loosely coupled design.

https://eli.thegreenplace.net/2023/the-power-of-single-method-interfaces-in-go/

The goal of this post was to discuss the prevalence and power of single-method interfaces (SMIs) in Go. It started by showing how SMIs can do whatever higher-order functions (HOFs) can do (albeit somewhat more verbosely, given that the task at hand was tailored for HOFs in previous posts).

Then, we discussed additional capabilities of SMIs that make them unique and aren’t achievable with HOFs in a reasonable way.

In functional languages, HOFs are heavily used to implement sophisticated and useful abstractions. In Go, you can use HOFs as well but most Go code prefers to use SMIs for this purpose, because of the added generality.