Fixes #36185
Change-Id: I7634744e62e00023367ed48a4700b61a6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/729902
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
if params := f.Type.Params; len(params.List) != 0 {
continue // function has params; not a valid example
}
+ if results := f.Type.Results; results != nil && len(results.List) != 0 {
+ continue // function has results; not a valid example
+ }
if f.Body == nil { // ast.File.Body nil dereference (see issue 28044)
continue
}
func ExampleFunc1_foo_suffix() {}
func ExampleFunc1_foo_Suffix() {} // matches Func1, instead of Func1_foo
func Examplefunc1() {} // invalid - cannot match unexported
+func ExampleFunc1_params(a int) {} // invalid - has parameter
+func ExampleFunc1_results() int {} // invalid - has results
func ExampleType1_Func1() {}
func ExampleType1_Func1_() {} // invalid - suffix must start with a lower-case letter