Stringer is the conventional Go interface for values that provide a String() method returning custom textual formatting. Formatting functions such as fmt.Printf use that result automatically, making domain values more readable. section 5.5
A type satisfies Stringer structurally: it needs the required method, but no explicit declaration. Go checks satisfaction at compile time, while the -er naming convention makes single-method interfaces recognizable. section 5.5
Formatting measurement units
A Unit type can implement String() to return familiar abbreviations such as “g”, “kg”, “oz”, “lb”, “L”, and “gal”. Unknown values can fall back to their underlying string representation. section 5.5
type Stringer interface {
String() string
}
Inspect the minimal Stringer interface definition before comparing it with a concrete Unit implementation. section 5.5


