The error interface
An error is any type with a Error() string method:
type error interface {
Error() string
}
The standard library and your own code all implement this. Returning nil means success.
Is and As
Two helpers inspect error chains:
errors.Is(err, os.ErrNotExist) // match by value
var target *PathError
errors.As(err, &target) // match by type
Is compares errors (great with sentinel errors). As extracts a concrete typed error for further use.