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

New Rule for dangerous type casts #888

Closed
tdellmann opened this issue Sep 6, 2023 · 0 comments · Fixed by #889
Closed

New Rule for dangerous type casts #888

tdellmann opened this issue Sep 6, 2023 · 0 comments · Fixed by #889

Comments

@tdellmann
Copy link

A dynamic type cast like x := something(*somethingElse[]) can cause a panic. Because this can be extremely dangerous there should be a lint rule for it.

This rule should trigger if

  • a type ist dynamicly casted to a single value
  • a type is dynamicly casted and the second response value (ok) is ignored
    • the first result can be checked for nil - so this might be nice to configure
  • a dynamic type cast happens in a return statement

The alternative would be to always panic.recover() in bigger projects and just live with something as unsafe like

return ctx.Value("myCoolErrorChan").(chan err)
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

Successfully merging a pull request may close this issue.

1 participant