summaryrefslogtreecommitdiff
path: root/prompts/skills/100-go-mistakes/references/mistake-50-comparing-an-error-type-inaccurately.md
blob: dfea107efba3c7f0fd2f673cd0188b7b97c19841 (plain)
1
2
3
4
5
6
# Mistake #50: Comparing an error type inaccurately


If you use Go 1.13 error wrapping with the `%w` directive and `fmt.Errorf`, comparing an error against a type has to be done using `errors.As`. Otherwise, if the returned error you want to check is wrapped, it will fail the checks.

[Source code](https://github.com/teivah/100-go-mistakes/tree/master/src/07-error-management/50-compare-error-type/main.go)