go.tools/cover: clean up usage information

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/13532052
This commit is contained in:
Nathan John Youngman 2013-09-24 17:27:26 +10:00 committed by Rob Pike
parent 1d41279086
commit 84cae5a52d
1 changed files with 20 additions and 11 deletions

View File

@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// Cover is a program for analyzing the coverage profiles generated by
// 'go test -coverprofile'.
// 'go test -coverprofile=cover.out'.
//
// Cover is also used by 'go test -cover' to rewrite the source code with
// annotations to track which parts of each function are executed.
@ -12,6 +12,10 @@
// than binary-rewriting coverage tools, but also a little less capable.
// For instance, it does not probe inside && and || expressions, and can
// be mildly confused by single statements with multiple function literals.
//
// For usage information, please see:
// go help testflag
// go tool cover -help
package main
import (
@ -30,23 +34,28 @@ import (
const usageMessage = "" +
`Usage of 'go tool cover':
Given a coverage profile produced by 'go test -coverprofile=c.out', open
a web browser displaying annotated source code:
go tool cover -html=c.out
The same, but write the generated HTML to a file instead of starting a browser:
go tool cover -html=c.out -o coverage.html
Write to standard output coverage percentages for each function:
go tool cover -func=c.out
Generate modified source code with coverage annotations (what go test -cover does):
go tool cover -mode=set -var=CoverageVariableName program.go
Given a coverage profile produced by 'go test':
go test -coverprofile=c.out
Only one of -html, -func, or -mode may be set.
Open a web browser displaying annotated source code:
go tool cover -html=c.out
Write out an HTML file instead of launching a web browser:
go tool cover -html=c.out -o coverage.html
Display coverage percentages to stdout for each function:
go tool cover -func=c.out
Finally, to generate modified source code with coverage annotations
(what go test -cover does):
go tool cover -mode=set -var=CoverageVariableName program.go
`
func usage() {
fmt.Fprintln(os.Stderr, usageMessage)
fmt.Fprintln(os.Stderr, "Flags:")
flag.PrintDefaults()
fmt.Fprintln(os.Stderr, "\n Only one of -html, -func, or -mode may be set.")
os.Exit(2)
}