From: Michael Matloob Date: Mon, 16 Dec 2019 22:20:02 +0000 (-0500) Subject: src/go/doc: in Examples, check for len of params.List, not nilness X-Git-Tag: go1.14rc1~230 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4b21702fdcd17aee6a52a74cc68c7c9b0ed1b7e3;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- diff --git a/src/go/doc/example.go b/src/go/doc/example.go index 868db8a23f..a010d3a85a 100644 --- a/src/go/doc/example.go +++ b/src/go/doc/example.go @@ -62,7 +62,7 @@ func Examples(testFiles ...*ast.File) []*Example { if !ok || f.Recv != nil { 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 } numDecl++