mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.73k stars 276 forks source link

New Rule for dangerous type casts #888

Closed tdellmann closed 11 months ago

tdellmann commented 11 months ago

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

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)