Frequently when writing tests, we end up comparing two error values, on of which may be
nil. It would be useful to have an errors.Equal() function, which can execute a
nil-safe comparison. This is the function, which we've been copy-and-pasting around our
test packages:
func Equal(a, b error) bool {
if a == nil {
return b == nil
}
return b != nil && a.Error() == b.Error()
}