AI Features

The error Data Type

Let’s learn about the error data type.

The error interface

Let’s revisit the error data type, which is an interface defined as follows:

type error interface {
Error() string
}

So, in order to satisfy the error interface, we just need to implement the Error() string type method. This does not change the way we use errors to find out whether the execution of a function or method was successful or not, but it shows how important interfaces are in Go as they are being used transparently all the time. However, the crucial question is when we ...