Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fhs/golinecov
A program for analyzing the coverage profiles generated by 'go test'
https://github.com/fhs/golinecov
command-line-tool coverage go golang
Last synced: 3 days ago
JSON representation
A program for analyzing the coverage profiles generated by 'go test'
- Host: GitHub
- URL: https://github.com/fhs/golinecov
- Owner: fhs
- License: bsd-3-clause
- Created: 2019-09-06T02:26:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-06T02:33:03.000Z (about 5 years ago)
- Last Synced: 2024-06-20T17:31:28.516Z (5 months ago)
- Topics: command-line-tool, coverage, go, golang
- Language: Go
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/fhs/golinecov?status.svg)](https://godoc.org/github.com/fhs/golinecov)
[![Go Report Card](https://goreportcard.com/badge/github.com/fhs/golinecov)](https://goreportcard.com/report/github.com/fhs/golinecov)## golinecov
Golinecov is a tool for analyzing the coverage profiles generated by
`go test -coverprofile=go.cover`. It can output source code annotated
with coverage per-line in plain-text format, which is an alternative
to generating HTML with [`go tool cover -html`](https://golang.org/cmd/cover/) and opening it in a web brower.## Installation
go get github.com/fhs/golinecov
## Example Usage
Generate the coverage profile and call it `go.cover` because `golinecov`
looks for a profile with that name by default:
```
$ cd $GOROOT/go/src/strings
$ go test -covermode=atomic -coverprofile=go.cover
```Display source of `Builder.Grow` annotated with coverage per-line:
```
$ golinecov -src -func '^Builder\.Grow$'
10883 func (b *Builder) Grow(n int) {
10883 b.copyCheck()
0 if n < 0 {
0 panic("strings.Builder.Grow: negative count")
- }
10778 if cap(b.buf)-len(b.buf) < n {
10778 b.grow(n)
10778 }
- }
```Display file `strings/builder.go`, annotated with coverage per-line:
```
$ golinecov -src strings/builder.go
...
97.4% strings/builder.go
```Display summary of coverage for all files in the profile:
```
$ golinecov
97.4% strings/builder.go
100.0% strings/compare.go
95.8% strings/reader.go
96.8% strings/replace.go
100.0% strings/search.go
99.0% strings/strings.go
```Display summary of coverage for functions matching a regular expression:
```
$ golinecov -func '^Builder\.'
strings/builder.go:32: Builder.copyCheck 100.0%
strings/builder.go:46: Builder.String 100.0%
strings/builder.go:51: Builder.Len 100.0%
strings/builder.go:56: Builder.Cap 100.0%
strings/builder.go:59: Builder.Reset 100.0%
strings/builder.go:66: Builder.grow 100.0%
strings/builder.go:75: Builder.Grow 80.0%
strings/builder.go:87: Builder.Write 100.0%
strings/builder.go:95: Builder.WriteByte 100.0%
strings/builder.go:103: Builder.WriteRune 100.0%
strings/builder.go:120: Builder.WriteString 100.0%
total: (statements) 97.2%
```