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

ErrorAs warning when using generic target #213

Open
uudashr opened this issue Jan 4, 2025 · 0 comments
Open

ErrorAs warning when using generic target #213

uudashr opened this issue Jan 4, 2025 · 0 comments
Labels
false-positive Checker's false positive example

Comments

@uudashr
Copy link

uudashr commented Jan 4, 2025

Below code works, but it shows warning

error-is-as: second argument to require.ErrorAs must be a non-nil pointer to either a type that implements error, or to any interface type (testifylint) go-golangci-lint

package requirekit

import (
  "github.com/stretchr/testify/require"
)

func ErrorAs[T error]() require.ErrorAssertionFunc {
  return func(t require.TestingT, err error, msgAndArgs ...interface{}) {
    var target *T
    require.ErrorAs(t, err, &target, msgAndArgs...)
  }
}
@Antonboom Antonboom added the false-positive Checker's false positive example label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive Checker's false positive example
Projects
None yet
Development

No branches or pull requests

2 participants