We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Last version golangci-lint use errcheck v1.8.0 Now errcheck gives alerts for code like:
var a interface{} a = 5 switch a.(type) { case string: fmt.Println("this is string", a.(string)) case int: fmt.Println("this is int", a.(int)) default: fmt.Println("unknown type") }
I think it is related to changes from #246 I believe that it is false-positive, because type is checked in switch-case
The text was updated successfully, but these errors were encountered:
Here's a test case if someone wants to have a crack at fixing this:
--- a/errcheck/testdata/src/assert/main.go +++ b/errcheck/testdata/src/assert/main.go @@ -1,5 +1,7 @@ package assert +import "fmt" + func main() { var i interface{} _ = i.(string) // want "unchecked error" @@ -16,6 +18,18 @@ func main() { _ = i.(int) // want "unchecked error" case nil: } + + var a interface{} + a = 5 + + switch a.(type) { + case string: + fmt.Println("this is string", a.(string)) + case int: + fmt.Println("this is int", a.(int)) + default: + fmt.Println("unknown type") + } }
Sorry, something went wrong.
Current errcheck behavior is consistent with gopls. Recommended action is to reassign variable to make it assume the resolved type
gopls
No branches or pull requests
Last version golangci-lint use errcheck v1.8.0
Now errcheck gives alerts for code like:
I think it is related to changes from #246
I believe that it is false-positive, because type is checked in switch-case
The text was updated successfully, but these errors were encountered: