-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/cmd/deadcode: support -json, -format=template
This change adds support for JSON output and text/template formatting of output records, in the manner of 'go list (-f|-json)'. Plus test. Also, the -generated flag is now enabled by default, and it affects all output modes. Plus test. Updates golang/go#63501 Change-Id: I1374abad78d800f92739de5c75b28e6e5189caa1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/539661 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
Showing
6 changed files
with
231 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Test of -generated flag output. | ||
|
||
deadcode example.com | ||
!want "main" | ||
want "Dead1" | ||
!want "Dead2" | ||
|
||
deadcode -generated example.com | ||
!want "main" | ||
want "Dead1" | ||
want "Dead2" | ||
|
||
-- go.mod -- | ||
module example.com | ||
go 1.18 | ||
|
||
-- main.go -- | ||
package main | ||
|
||
func main() {} | ||
func Dead1() {} | ||
|
||
-- gen.go -- | ||
// Code generated by hand. DO NOT EDIT. | ||
|
||
package main | ||
|
||
func Dead2() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Very minimal test of -json flag. | ||
|
||
deadcode -json example.com/p | ||
|
||
want `"Path": "example.com/p",` | ||
want `"Name": "example.com/p.Dead",` | ||
want `"RelName": "Dead",` | ||
want `"Generated": false` | ||
|
||
-- go.mod -- | ||
module example.com | ||
go 1.18 | ||
|
||
-- p/p.go -- | ||
package main | ||
|
||
func Dead() {} | ||
|
||
func main() {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters