Commit 4b21702f authored by Michael Matloob's avatar Michael Matloob

src/go/doc: in Examples, check for len of params.List, not nilness

This makes the check the same as the one in the tests vet check.
It's safer to check the number of arguments rather than for a nil
slice.

Change-Id: I8e04e9c612573f334770c1c4245238649656c6e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/211598
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent a5bfd9da
...@@ -62,7 +62,7 @@ func Examples(testFiles ...*ast.File) []*Example { ...@@ -62,7 +62,7 @@ func Examples(testFiles ...*ast.File) []*Example {
if !ok || f.Recv != nil { if !ok || f.Recv != nil {
continue continue
} }
if params := f.Type.Params; params.List != nil { if params := f.Type.Params; len(params.List) != 0 {
continue // function has params; not a valid example continue // function has params; not a valid example
} }
numDecl++ numDecl++
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment