diff --git a/src/cmd/doc/doc_test.go b/src/cmd/doc/doc_test.go index f8c52b1988baa2..0761c6ddb3b0fe 100644 --- a/src/cmd/doc/doc_test.go +++ b/src/cmd/doc/doc_test.go @@ -481,6 +481,26 @@ var tests = []test{ `unexportedTypedConstant`, // No unexported constant. }, }, + // Type -all. + { + "type", + []string{"-all", p, `ExportedType`}, + []string{ + `type ExportedType struct {`, // Type definition as source. + `Comment about exported type`, // Include comment afterwards. + `const ConstGroup4 ExportedType = ExportedType\{\}`, // Related constants. + `ExportedTypedConstant ExportedType = iota`, + `Constants tied to ExportedType`, + `func ExportedTypeConstructor\(\) \*ExportedType`, + `Comment about constructor for exported type.`, + `func ReturnExported\(\) ExportedType`, + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `Comment about exported method.`, + }, + []string{ + `unexportedType`, + }, + }, // Type T1 dump (alias). { "type T1", diff --git a/src/cmd/doc/main.go b/src/cmd/doc/main.go index 614f19438c8cd4..ec15ec5826149a 100644 --- a/src/cmd/doc/main.go +++ b/src/cmd/doc/main.go @@ -133,10 +133,7 @@ func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) { } // We have a package. - if showAll { - if symbol != "" { - return fmt.Errorf("-all valid only for package, not symbol: %s", symbol) - } + if showAll && symbol == "" { pkg.allDoc() return }