Commit a2381f59 authored by Rob Pike's avatar Rob Pike Committed by Daniel Martí

cmd/doc: fix repeated header bug added in previous CL

One too many lines was deleted, and it would print a header multiple times.
Add a test.

Change-Id: I4906b454dbb66193d515ffacf43849ffdc2dede6
Reviewed-on: https://go-review.googlesource.com/c/142937Reviewed-by: default avatarRalph Corderoy <ralph@inputplus.co.uk>
Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 101a677e
...@@ -733,6 +733,9 @@ func TestDoc(t *testing.T) { ...@@ -733,6 +733,9 @@ func TestDoc(t *testing.T) {
failed = true failed = true
} }
} }
if bytes.Count(output, []byte("TYPES\n")) > 1 {
t.Fatalf("%s: repeating headers", test.name)
}
if failed { if failed {
t.Logf("\n%s", output) t.Logf("\n%s", output)
} }
......
...@@ -426,6 +426,7 @@ func (pkg *Package) allDoc() { ...@@ -426,6 +426,7 @@ func (pkg *Package) allDoc() {
printHdr := func(s string) { printHdr := func(s string) {
if hdr != s { if hdr != s {
pkg.Printf("\n%s\n\n", s) pkg.Printf("\n%s\n\n", s)
hdr = s
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment