Standard library / fmt
fmt.GoStringer
GoString() supplies Go-syntax-style representation when formatted with %#v (unless a higher-priority Formatter handles it). Expected stdout: 'label(7)\n'.
Formal Syntax & Structure
go syntaxgo
type GoStringer interface { GoString() string }Working Example
Example Snippetgo
package main
import ( "fmt")
type label int
func (l label) GoString() string { return fmt.Sprintf("label(%d)", int(l)) }func main() { fmt.Printf("%#v\n", label(7))}