Skip to content

Commit

Permalink
internal/cmd/deadcode: add -whylive=function flag
Browse files Browse the repository at this point in the history
The -whylive flag explains why a function is live (not dead code),
by displaying an arbitrary shortest path to the function from
one of the main entrypoints. Call paths from main packages (not tests),
from main functions (not init functions), and involving only
static calls are preferred.

The output logic is unified so that the usual mode and -whylive
both compute a list of JSON objects, which are then formatted
by -json or -format=template.

Also, a test.
Also, fix the test framework to correctly handle a sequence of commands(!).

Fixes golang/go#61263

Change-Id: I6aafc851c9c57e27a0a8f0d723e20fb2f8b57ad7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/540219
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
adonovan committed Nov 7, 2023
1 parent b753e58 commit c538b4e
Show file tree
Hide file tree
Showing 5 changed files with 441 additions and 119 deletions.
Loading

0 comments on commit c538b4e

Please # to comment.