New (Errorf) in Go

Posted by GoDoc
Public (Editable by Users)

The fmt package's Errorf function lets us use the package's formatting features to create descriptive error messages.

Go
Edit
package main

import "fmt"

func main() {
	const name, id = "bimmler", 17
	err := fmt.Errorf("user %q (id %d) not found", name, id)
	if err != nil {
		fmt.Print(err)
	}
}