Golang fmt.Errorf() function examples

package fmt

Errorf formats according to a format specifier and returns the string as a value that satisfies error.

Golang fmt.Errorf() function usage examples

Example 1 :

 connection, err := amqp.Dial(amqpURI)
 if err != nil {
  return fmt.Errorf("Dial: %s", err)
 }

Example 2 :

 query.Error = fmt.Errorf("Multi Oid Walk not supported")

Reference :

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

Advertisement