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

Unwrapping errors.Join error to []error through type assertion. #61

Closed
forgoty opened this issue Nov 28, 2023 · 1 comment
Closed

Unwrapping errors.Join error to []error through type assertion. #61

forgoty opened this issue Nov 28, 2023 · 1 comment

Comments

@forgoty
Copy link

forgoty commented Nov 28, 2023

I am trying to type assert multiples errors created with errors.Join

err := errors.Join(errors.New("err1"), errors.New("err2"))
errs, ok := err.(interface{ Unwrap() []error })

This code results in a warning:

type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
        errs, ok := err.(interface{ Unwrap() []error })
                    ^

This is a valid case for me from go 1.20. Seems should be whitelisted.

@polyfloyd
Copy link
Owner

Fixed! Thanks for reporting :)

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