Skip to content

Commit f2131f6

Browse files
mostynbgriesemer
authored andcommitted
doc.Example should not worry about unresolved blank identifiers
https://golang.org/pkg/bufio/#example_Scanner_custom is not directly runnable in the playground via godoc, but if I copy+paste the code into https://play.golang.org/ then it runs just fine. This seems to be due to the blank identifier being considered unresolved in the following line in the example: _, err = strconv.ParseInt(string(token), 10, 32) But that's the whole point of blank identifiers- they're not supposed to be resolved. So let's skip adding the blank identifier to doc.playExample's unresolved map. Fixes #26447 Change-Id: I52bc7d99be1d14a61dc012d10c18349d52ba4c51 GitHub-Last-Rev: 9172e9d GitHub-Pull-Request: #26448 Reviewed-on: https://go-review.googlesource.com/124775 Reviewed-by: Robert Griesemer <[email protected]>
1 parent 6b937ac commit f2131f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/go/doc/example.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func playExample(file *ast.File, f *ast.FuncDecl) *ast.File {
188188
inspectFunc = func(n ast.Node) bool {
189189
switch e := n.(type) {
190190
case *ast.Ident:
191-
if e.Obj == nil {
191+
if e.Obj == nil && e.Name != "_" {
192192
unresolved[e.Name] = true
193193
} else if d := topDecls[e.Obj]; d != nil {
194194
if !hasDepDecls[d] {

0 commit comments

Comments
 (0)