Predeclared type

Go error type

Predeclared interface with Error() string. A nil interface conventionally means no error; an interface containing a typed nil pointer is not nil. Example output: 'invalid input'.

Formal Syntax & Structure

go syntaxgo
error

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt")
func main() {  var err error = errors.New("invalid input")  fmt.Println(err.Error())}
Go Reference