Standard library / fmt
fmt.Formatter
Format receives a State and verb, overriding ordinary formatting. Implementations must decide how to handle flags, width and precision. Expected stdout: 'label=7\n'.
Formal Syntax & Structure
go syntaxgo
type Formatter interface { Format(f State, verb rune) }Working Example
Example Snippetgo
package main
import ( "fmt")
type label int
func (l label) Format(s fmt.State, v rune) { fmt.Fprintf(s, "label=%d", int(l)) }func main() { fmt.Printf("%v\n", label(7))}