Working with Errors in Go 1.13
Explains the intended use of `%w`, `errors.Is`, `errors.As`, and wrapper error conventions.
Explains the intended use of %w, errors.Is, errors.As, and wrapper error conventions.
- Author: Damien Neil and Jonathan Amsterdam
- Authority: primary
- Kind: blog
- URL: https://go.dev/blog/go1.13-errors
What it covers
- wrapping with %w
- inspection with errors.Is and errors.As
- design of wrapper errors
Why authoritative
Official Go blog guidance for the modern error-wrapping model.
Use when
- how should Go 1.13 style error wrapping work
- when should I use %w in fmt.Errorf
- how are wrapped errors supposed to be inspected
Keywords
- go1.13 errors, wrapping, errors.Is, errors.As, fmt.Errorf