-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go/parser: example for ParseFile fails on golang.org (playground) #19823
Comments
The example is being run in the (Go Playground)[https://play.golang.org/] Does the example work when you copy it to a new package and include a valid 'example_test.go' file? |
The example depends on its own file in the I guess a way to make it work in the playground would be for the example to first write a file to disk, or to use a buffer/string as the source. |
I'll write up a quick CL doing that. |
In (Inside the Go Playground)[https://blog.golang.org/playground] its mentioned that zip files may be uploaded for the purpose of examples. Perhaps uploading |
I think that's a bit overkill. If the purpose of the example was precisely to use a file via |
CL https://golang.org/cl/39236 mentions this issue. |
The example shouldn't rely on the existance of example_test.go. That breaks in the playground, which is what the "run" button in https://golang.org/pkg/go/parser/#example_ParseFile does. Make the example self-sufficient by using a small piece of source via a string literal instead. Fixes golang#19823. Change-Id: Ie8a3c6c5d00724e38ff727862b62e6a3621adc88 Reviewed-on: https://go-review.googlesource.com/39236 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Robert Griesemer <gri@golang.org>
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?n/a (error is on golang.org)
What operating system and processor architecture are you using (
go env
)?n/a
What did you do?
Visit https://golang.org/pkg/go/parser/#example_ParseFile (specifically, the example for ParseFile).
Click Run to run the example.
What did you expect to see?
Output of the program.
What did you see instead?
open example_test.go: No such file or directory
Program exited.
The text was updated successfully, but these errors were encountered: