From d7b4428c1ff29920309571414b1f957df3206b3b Mon Sep 17 00:00:00 2001 From: Gert Cuykens Date: Fri, 18 Oct 2019 04:13:50 +0200 Subject: [PATCH] cmd/doc: flag usage() inconsistency 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 TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- src/cmd/doc/main.go | 7 +-- src/cmd/go/testdata/script/doc.txt | 75 ++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 src/cmd/go/testdata/script/doc.txt diff --git a/src/cmd/doc/main.go b/src/cmd/doc/main.go index 86259e5f1f..0499c40369 100644 --- a/src/cmd/doc/main.go +++ b/src/cmd/doc/main.go @@ -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 \n") - fmt.Fprintf(os.Stderr, "\tgo doc [.]\n") - fmt.Fprintf(os.Stderr, "\tgo doc [].[.]\n") - fmt.Fprintf(os.Stderr, "\tgo doc [.]\n") + fmt.Fprintf(os.Stderr, "\tgo doc [.]\n") + fmt.Fprintf(os.Stderr, "\tgo doc [.][.]\n") + fmt.Fprintf(os.Stderr, "\tgo doc [.][.]\n") + fmt.Fprintf(os.Stderr, "\tgo doc [.]\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 index 0000000000..3ff1aab093 --- /dev/null +++ b/src/cmd/go/testdata/script/doc.txt @@ -0,0 +1,75 @@ +# go doc --help +! go doc --help +stderr 'go doc' +stderr 'go doc ' +stderr 'go doc \[\.\]' +stderr 'go doc \[\.\]\[\.\]' +stderr 'go doc \[\.\]\[\.\]' +stderr 'go doc \[\.\]' + +# go help doc +go help doc +stdout 'go doc' +stdout 'go doc ' +stdout 'go doc \[\.\]' +stdout 'go doc \[\.\]\[\.\]' +stdout 'go doc \[\.\]\[\.\]' +stdout 'go doc \[\.\]' + +# go doc +go doc p/v2 +stdout . + +# go doc +go doc p/v2 Symbol +stdout . + +# go doc +! go doc p/v2 Symbol Method +stderr . + +# go doc . +go doc p/v2.Symbol +stdout . + +# go doc .. +go doc p/v2.Symbol.Method +stdout . + +# go doc +go doc Symbol +stdout . + +# go doc +! go doc Symbol Method +stderr . + +# go doc . +go doc Symbol.Method +stdout . + +# go doc . +go doc p/v2.Method +stdout . + +# go doc +go doc p/v2 Method +stdout . + +# go doc +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 +} -- 2.50.0