deadcode from x/tools has some awkward assumptions and error UX:
- deadcode assumes that all Go projects have an application (main package) and/or a unit test suite. But some Go projects merely implement convenience wrappers around other CLI tools, so there’s no main package, nor not much to test.
- Even though deadcode assumes that every project has a main package and/or a unit test suite, deadcode currently disables unit test scanning by default.
-test
should be the default behavior. It’s reasonable to assume that every Go project has at least one unit test. If they don’t, that’s generally a code smell, and there should be a way to disable-test
as opt-out rather than opt-in. - The error message when neither a main package nor unit test is available is confusing and misleading:
deadcode: no main packages
. For example, the error message should clarify that a main package and/or a unit test would also be sufficient to help it conduct a scan.