// htmlOutput reads the profile data from profile and generates an HTML // coverage report, writing it to outfile. If outfile is empty, // it writes the report to a temporary file and opens it in a web browser. func htmlOutput(profile, outfile string) error { … } // percentCovered returns, as a percentage, the fraction of the statements in // the profile covered by the test run. // In effect, it reports the coverage of a given source file. func percentCovered(p *cover.Profile) float64 { … } // htmlGen generates an HTML coverage report with the provided filename, // source code, and tokens, and writes it to the given Writer. func htmlGen(w io.Writer, src []byte, boundaries []cover.Boundary) error { … } // rgb returns an rgb value for the specified coverage value // between 0 (no coverage) and 10 (max coverage). func rgb(n int) string { … } // colors generates the CSS rules for coverage colors. func colors() template.CSS { … } var htmlTemplate … type templateData … // PackageName returns a name for the package being shown. // It does this by choosing the penultimate element of the path // name, so foo.bar/baz/foo.go chooses 'baz'. This is cheap // and easy, avoids parsing the Go file, and gets a better answer // for package main. It returns the empty string if there is // a problem. func (td templateData) PackageName() string { … } type templateFile … const tmplHTML …