cmd/doc: don't print a declaration twice

That can occur if we have -u set and there is an upper- and lower-case
name of the same spelling in a single declaration.

A rare corner case but easy to fix.

Fix by remembering what we've printed.

Fixes #21797.

Change-Id: Ie0b681ae8c277fa16e9635ba594c1dff272b8aeb
Reviewed-on: https://go-review.googlesource.com/78715
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rob Pike 2017-11-20 14:12:43 +11:00
parent 363a5da3b8
commit 337f04bd6c
3 changed files with 25 additions and 1 deletions

View file

@ -445,6 +445,19 @@ var tests = []test{
`CaseMatch`,
},
},
// No dups with -u. Issue 21797.
{
"case matching on, no dups",
[]string{"-u", p, `duplicate`},
[]string{
`Duplicate`,
`duplicate`,
},
[]string{
"\\)\n+const", // This will appear if the const decl appears twice.
},
},
}
func TestDoc(t *testing.T) {