Fix match.As to behave the same as errors.As
Fixes #19
Thanks @Fryuni ! Can you please take a look at the failing tests?
Sure, they all passed locally on 1.17 🙃, I forgot to try on the previous versions
I fixed the compatibility problems (the %w formatting), but there is a bigger problem here.
errors.As extract the value in the error chain with the target type and assign it to the target pointer, this is useful to get inner data from the matched error. Writing to the pointer it receives makes it not concurrent-safe. To have the same behavior, match.As would also not be concurrent-safe. Since it is tested now to be concurrent, I think changing it would qualify as a breaking change.
I can remove the race test or change just the matching logic to be the same as errors.As without assigning to the pointer. It seems the latter was the intention of the current code but in that case, I think I should add a match.AsAssign/AsShape or something like that
WDYT @sagikazarmark ?
@sagikazarmark just going through my open PRs, any thoughts on this? 😄