Golang fmt.Scanner type example

package fmt

Scanner is implemented by any value that has a Scan method, which scans the input for the representation of a value and stores the result in the receiver, which must be a pointer to be useful. The Scan method is called for any argument to Scan, Scanf, or Scanln that implements it.

Golang fmt.Scanner type usage example

 var arg interface{}
 var err error
 var verb rune
 var s fmt.ScanState

 // If the parameter has its own Scan method, use that.
 if v, ok := arg.(Scanner); ok {
 err = v.Scan(s, verb)
  if err != nil {
  if err == io.EOF {
 err = io.ErrUnexpectedEOF
  }
 }

Reference :

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

Advertisement