Skip to content

Commit 2638d66

Browse files
committed
internal/cmd/deadcode: omit package/func keywords in default output
...and don't quote the package path. Updates golang/go#63501 Change-Id: Ic4f52bf74d7ddd185f2179deed55118971bfa7ed Reviewed-on: https://go-review.googlesource.com/c/tools/+/540218 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 118c362 commit 2638d66

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

internal/cmd/deadcode/deadcode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ func main() {
308308
for _, fn := range pkg.Funcs {
309309
if !seen {
310310
seen = true
311-
fmt.Printf("package %q\n", pkg.Path)
311+
fmt.Println(pkg.Path)
312312
}
313-
fmt.Printf("\tfunc %s\n", fn.RelName)
313+
fmt.Printf("\t%s\n", fn.RelName)
314314
}
315315
if seen {
316316
fmt.Println()

internal/cmd/deadcode/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ With the -format=template flag, the command executes the specified template
8080
on each Package record. So, this template produces a result similar to the
8181
default format:
8282
83-
-format='{{printf "package %q\n" .Path}}{{range .Funcs}}{{println "\tfunc " .RelName}}{{end}}{{println}}'
83+
-format='{{println .Path}}{{range .Funcs}}{{printf "\t%s\n" .RelName}}{{end}}{{println}}'
8484
8585
And this template shows only the list of source positions of dead functions:
8686

internal/cmd/deadcode/testdata/basic.txtar

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
deadcode -filter= example.com
44

5-
want "func (T).Goodbye"
6-
!want "func (T).Hello"
7-
want "func unreferenced"
5+
want "(T).Goodbye"
6+
!want "(T).Hello"
7+
want "unreferenced"
88

9-
want "func Scanf"
10-
want "func Printf"
11-
!want "func Println"
9+
want "Scanf"
10+
want "Printf"
11+
!want "Println"
1212

1313
-- go.mod --
1414
module example.com

internal/cmd/deadcode/testdata/filterflag.txtar

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
deadcode -filter=other.net example.com
44

5-
want `package "other.net"`
6-
want `func Dead`
7-
!want `func Live`
5+
want `other.net`
6+
want `Dead`
7+
!want `Live`
88

9-
!want `package "example.com"`
10-
!want `func unreferenced`
9+
!want `example.com`
10+
!want `unreferenced`
1111

1212
-- go.work --
1313
use example.com

internal/cmd/deadcode/testdata/testflag.txtar

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
deadcode -test -filter=example.com example.com/p
44

5-
want "func Dead"
6-
!want "func Live1"
7-
!want "func Live2"
5+
want "Dead"
6+
!want "Live1"
7+
!want "Live2"
88

9-
want "func ExampleDead"
10-
!want "func ExampleLive"
9+
want "ExampleDead"
10+
!want "ExampleLive"
1111

1212
-- go.mod --
1313
module example.com

0 commit comments

Comments
 (0)