Golang fmt.Formatter type example

package fmt

Formatter is the interface implemented by values with a custom formatter. The implementation of Format may call Sprint(f) or Fprint(f) etc. to generate its output.

Golang fmt.Formatter type usage examples

Example 1 :

 func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter {
 fs := &formatState{value: v, cs: cs}
 fs.pointers = make(map[uintptr]int)
 return fs
 }

Reference :

http://golang.org/pkg/fmt/#Formatter

Advertisement