That's what `errors.Is` is for.
https://pkg.go.dev/errors#Is
Note that you don't need custom error types, just exported Error instances. These were in use even before wrapping was introduced with Go 1.13 (2019); one had to compare or type-assert directly instead of unwrapping.