From 07d48993f257a6536d83555bb8cc9daffa07dd56 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Fri, 23 Oct 2015 17:09:39 -0700 Subject: cmd/doc: fix strange indentation artifacts with unexported fields The NamePos value was not being set, and would default to a value of zero. This would cause the printing logic to get confused as to where exactly to place the "Has unexported fields" string. A trivial package changes from < type A struct { A int // A B int // B // Has unexported fields. } > to < type A struct { A int // A B int // B // Has unexported fields. } > Fixes #12971 Change-Id: I53b7799a1f1c0ad7dcaddff83d9aaeb1d6b7823e Reviewed-on: https://go-review.googlesource.com/16286 Run-TryBot: Joe Tsai TryBot-Result: Gobot Gobot Reviewed-by: Rob Pike --- src/cmd/doc/testdata/pkg.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/cmd/doc/testdata') diff --git a/src/cmd/doc/testdata/pkg.go b/src/cmd/doc/testdata/pkg.go index 0f06651d6b..3e7acee50b 100644 --- a/src/cmd/doc/testdata/pkg.go +++ b/src/cmd/doc/testdata/pkg.go @@ -60,7 +60,7 @@ func internalFunc(a int) bool // Comment about exported type. type ExportedType struct { // Comment before exported field. - ExportedField int + ExportedField int // Comment on line with exported field. unexportedField int // Comment on line with unexported field. } @@ -87,6 +87,13 @@ func ExportedTypeConstructor() *ExportedType { const unexportedTypedConstant ExportedType = 1 // In a separate section to test -u. +// Comment about exported interface. +type ExportedInterface interface { + // Comment before exported method. + ExportedMethod() // Comment on line with exported method. + unexportedMethod() // Comment on line with unexported method. +} + // Comment about unexported type. type unexportedType int -- cgit v1.3-5-g9baa