go/doc: Examples includes example functions with returns #36185
Labels
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
As documented at https://golang.org/pkg/testing#hdr-Examples, an example function is expected to have no parameters and no returns.
doc.Examples
considers functions with parameters as invalid examples and skips them.Unlike the
vet
pass,doc.Examples
does not check if there are results.That means both of these are recognized as examples by
doc.Examples
:It means
x/tools/cmd/godoc
and other tools that display documentation may show such invalid examples:godoc screenshot
go vet
catches this problem:Perhaps
doc.Examples
should be changed to treat functions with returns as invalid examples, like it does for functions with parameters, and not include them in its output./cc @griesemer @jayconrod @matloob @bcmills
(This is somewhat related to issue #36184 and CL 211598.)
The text was updated successfully, but these errors were encountered: