Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect and unused Is() function #122

Open
Hades32 opened this issue May 16, 2022 · 1 comment
Open

Incorrect and unused Is() function #122

Hades32 opened this issue May 16, 2022 · 1 comment

Comments

@Hades32
Copy link

Hades32 commented May 16, 2022

While looking through the code I noticed this:

backoff/retry.go

Lines 99 to 102 in a78d380

func (e *PermanentError) Is(target error) bool {
_, ok := target.(*PermanentError)
return ok
}

Go doesn't support (yet) the Is(err) function for use in errors.Is(), and if it did then this implementation is fast but wrong for all wrapped errors.

Can we remove this? I think it's confusing and might break in the future

@seh
Copy link

seh commented Dec 21, 2023

@Hades32, can you clarify the "wrong for all wrapped errors" part? The current implementation of the errors.Is function will progress beyond an error's Is method that doesn't match the target error and inspect the wrapped errors revealed by an error's Unwrap method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants