Go has a built-in type for errors.
We can create our own errors by using the New function in the errors package:
package main //ww w . ja va 2 s . c o m import "errors" import "fmt" func main() { err := errors.New("error message") fmt.Println(err) }