Errors

Error handling is a very important topic in software engineering. There are plenty different schools of thought. Go's approach to it is very simple. It treates errors as values, and to some people unsufficient. But we won't get into this discussion here.

The error type is used to indicate an abnormal state. When this happens, there are several ways to act. In this chapter, we will only focus on the availability of tools that Go provides the developer to characterize and respond to these anomalies.

error is defined in the built-in package as:

type error interface {
    Error() string
}

However, this package provides nothing else than this interface. Most of the surrounding infrastructure is provided within the errors package instead.