prints struct in custom format in golang
type T struct {
a int
b float64
c string
}
func (t *T) String() string {
return fmt.Sprintf("%d____%g____%q", t.a, t.b, t.c)
}
func customFormat() {
t := &T{ 7, -2.35, "abc" }
fmt.Printf("%v\n", t) // output: 7____-2.35____"abc"
}
// default format: &{7 -2.35 abc}
// custom format: 7____-2.35____"abc"