]> Cypherpunks repositories - gostls13.git/commit
go/doc: ignore example functions with arguments
authorMichael Matloob <matloob@golang.org>
Fri, 13 Dec 2019 21:53:28 +0000 (16:53 -0500)
committerMichael Matloob <matloob@golang.org>
Mon, 16 Dec 2019 17:34:59 +0000 (17:34 +0000)
commit499dc1c5d583a2a0735d4e408078819b84697e2e
tree202ddf825cbd4e636f9615905e4a274ae6119a3c
parenta3dc6da6d6d25666d24bab293c0990d1b07bb798
go/doc: ignore example functions with arguments

An Example function with arguments is not a valid example to be
run with go test. Don't return those functions from Examples. This
means that some functions that were previously showing up in
Examples will no longer show up. But those functions were not being
tested properly so the fact that they were showing up is misleading.

This fixes an issue where a confusing compiler error was showing
up when running go test on a file with an invalid example. While
that issue could have been fixed by returning an error, this is
more consistent with the behavior of go/doc.Examples, and the tests
checker in vet will catch this issue.

Fixes #35284

Change-Id: I2101a7d19f38522ef9c2e50967f9cfb30d28c730
Reviewed-on: https://go-review.googlesource.com/c/go/+/211357
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/testdata/script/test_bad_example.txt [new file with mode: 0644]
src/go/doc/example.go