]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/doc: flag usage() inconsistency
authorGert Cuykens <gert.cuykens@gmail.com>
Fri, 18 Oct 2019 02:13:50 +0000 (04:13 +0200)
committerBryan C. Mills <bcmills@google.com>
Wed, 18 Dec 2019 17:57:19 +0000 (17:57 +0000)
Inconsistency between cmd/doc/main.go and cmd/go/internal/doc/doc.go

Fixes #34976

Change-Id: I429200f9305d473edb4505216bb4840ba92af818
Reviewed-on: https://go-review.googlesource.com/c/go/+/201857
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/doc/main.go
src/cmd/go/testdata/script/doc.txt [new file with mode: 0644]

index 86259e5f1f742b70f642000791bab3cdd1791618..0499c403695247035687054c0700fe28500a0b57 100644 (file)
@@ -65,9 +65,10 @@ func usage() {
        fmt.Fprintf(os.Stderr, "Usage of [go] doc:\n")
        fmt.Fprintf(os.Stderr, "\tgo doc\n")
        fmt.Fprintf(os.Stderr, "\tgo doc <pkg>\n")
-       fmt.Fprintf(os.Stderr, "\tgo doc <sym>[.<method>]\n")
-       fmt.Fprintf(os.Stderr, "\tgo doc [<pkg>].<sym>[.<method>]\n")
-       fmt.Fprintf(os.Stderr, "\tgo doc <pkg> <sym>[.<method>]\n")
+       fmt.Fprintf(os.Stderr, "\tgo doc <sym>[.<methodOrField>]\n")
+       fmt.Fprintf(os.Stderr, "\tgo doc [<pkg>.]<sym>[.<methodOrField>]\n")
+       fmt.Fprintf(os.Stderr, "\tgo doc [<pkg>.][<sym>.]<methodOrField>\n")
+       fmt.Fprintf(os.Stderr, "\tgo doc <pkg> <sym>[.<methodOrField>]\n")
        fmt.Fprintf(os.Stderr, "For more information run\n")
        fmt.Fprintf(os.Stderr, "\tgo help doc\n\n")
        fmt.Fprintf(os.Stderr, "Flags:\n")
diff --git a/src/cmd/go/testdata/script/doc.txt b/src/cmd/go/testdata/script/doc.txt
new file mode 100644 (file)
index 0000000..3ff1aab
--- /dev/null
@@ -0,0 +1,75 @@
+# go doc --help
+! go doc --help
+stderr 'go doc'
+stderr 'go doc <pkg>'
+stderr 'go doc <sym>\[\.<methodOrField>\]'
+stderr 'go doc \[<pkg>\.\]<sym>\[\.<methodOrField>\]'
+stderr 'go doc \[<pkg>\.\]\[<sym>\.\]<methodOrField>'
+stderr 'go doc <pkg> <sym>\[\.<methodOrField>\]'
+
+# go help doc
+go help doc
+stdout 'go doc'
+stdout 'go doc <pkg>'
+stdout 'go doc <sym>\[\.<methodOrField>\]'
+stdout 'go doc \[<pkg>\.\]<sym>\[\.<methodOrField>\]'
+stdout 'go doc \[<pkg>\.\]\[<sym>\.\]<methodOrField>'
+stdout 'go doc <pkg> <sym>\[\.<methodOrField>\]'
+
+# go doc <pkg>
+go doc p/v2
+stdout .
+
+# go doc <pkg> <sym>
+go doc p/v2 Symbol
+stdout .
+
+# go doc <pkg> <sym> <method>
+! go doc p/v2 Symbol Method
+stderr .
+
+# go doc <pkg>.<sym>
+go doc p/v2.Symbol
+stdout .
+
+# go doc <pkg>.<sym>.<method>
+go doc p/v2.Symbol.Method
+stdout .
+
+# go doc <sym>
+go doc Symbol
+stdout .
+
+# go doc <sym> <method>
+! go doc Symbol Method
+stderr .
+
+# go doc <sym>.<method>
+go doc Symbol.Method
+stdout .
+
+# go doc <pkg>.<method>
+go doc p/v2.Method
+stdout .
+
+# go doc <pkg> <method>
+go doc p/v2 Method
+stdout .
+
+# go doc <method>
+go doc Method
+stdout .
+
+-- go.mod --
+module p/v2
+
+go 1.13
+
+-- p.go --
+package p
+
+type Symbol struct{}
+
+func (Symbol) Method() error {
+       return nil
+}