Skip to content

proposal: cmd/cover: add flags to print coverage percentages over packages or files #45846

@chiawendt

Description

@chiawendt

Command cover can print coverage summary for each functions with go tool cover -func=c.out. But sometimes it is too much detail for me. The report would be more readable if the coverage summary were grouped by files or packages.

Examples:

$ go tool cover -func=out
root/a/foo.go:10:		fooF			20%
root/a/foo.go:20:		fooG			30%
root/a/foo.go:30:		fooH			30%
root/a/foo2.go:30: 		foo2F			30%
root/b/goo.go:30:		gooF			50%
root/b/goo.go:40:		gooG			50%

# imaginary flag 
$ go tool cover -summary-for-files=out
root/a/foo.go			90%
root/a/foo2.go			90%
root/b/goo.go			70%

# imaginary flag
$ go tool cover -summary-for-packages=out
root/a			90%
root/b			90%

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Hold

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions