|
|
|
|
|
by simiones
574 days ago
|
|
Your example is half right, I had misread the documentation of errors.As [0]. errors.As does work as you describe, but errors.Is doesn't: that only compares the error argument for equality, unless it implements Is() itself to do something different. So `var e error ErrType{Code: 1, Message: "Good"} = errors.Is(e, ErrType{})` will return false. But indeed Errors.As will work for this case and allow you to check if an error is an instance of ErrType. [0] https://play.golang.com/p/qXj3SMiBE2K |
|