You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One major benefit of having deadcode report on this is that it has the ability to determine dead functions through its reachability analysis. This ensures that usages of types / constants from dead functions do not result in a type / constant being marked as live, similar to how unusedFunc2 is correctly marked as unreachable by deadcode today despite it being called from unusedFunc.
In contrast, IDEs or other static analysis tools will many times correctly determine unusedConst or unused are dead code, but are not able to determine that usedButDeadConst or usedButDead are also.
The text was updated successfully, but these errors were encountered:
I agree this would be a nice feature for deadcode. This is essentially the same idea as #64945, but including constants too, so let's merge the issues.
Proposal Details
The
cmd/deadcode
tool currently reports on unreachable functions / methods, but doesn't report on unused types / constants. For example:main.go
The output of
deadcode .
in this package is:where as the ideal output after this proposal is implemented would be something like:
One major benefit of having
deadcode
report on this is that it has the ability to determine dead functions through its reachability analysis. This ensures that usages of types / constants from dead functions do not result in a type / constant being marked as live, similar to howunusedFunc2
is correctly marked as unreachable bydeadcode
today despite it being called fromunusedFunc
.In contrast, IDEs or other static analysis tools will many times correctly determine
unusedConst
orunused
are dead code, but are not able to determine thatusedButDeadConst
orusedButDead
are also.The text was updated successfully, but these errors were encountered: