website: don't show un-runnable examples as runnable #9679
The example for exec.Command won't run in the playground sandbox because it depends on 'tr'.
There are other such examples. We should probably detect (somehow) that they won't run, and not display them as runnable examples on golang.org.
Did a quick run through of stdlib examples.
There were some I couldn't check because #23095 seems to effect quite a few examples.
Other than os/exec, the patterns I saw were:
A lot of tests aren't playable due to files not existing. For the go/* packages this would be fixed by #23603. For the rest that use files, they appear to fall into two categories:
https://golang.org/pkg/crypto/x509/#example_Certificate_Verify runs locally but fails on the playground with "certificate has expired or is not yet valid", presumably because of the fake time.
https://golang.org/pkg/log/syslog/#example_Dial doesn't run because syslog.Dial isn't defined on nacl
I'm 99.999% sure this example deadlocking is a bug but will leave it up to the experts: https://golang.org/pkg/net/#example_Listener Similarly for https://golang.org/pkg/net/http/#example_Get replying "Get http://www.google.com/robots.txt: dial tcp: Protocol not available"
Some of these examples have output and some don't. If they all did that could be used to build a static list of non-runnable examples. (But then it's not clear if they're not runnable due to programmer error or playground limitations).
Given the variety and subtlety among the examples that don't run, maybe an annotation like
If the examples that cannot ever be run on the playground are tagged as such, there could probably be some sort of playground trybot that makes sure examples match their output when run on the playground.
64 examples out of 610 in go/src/... won't run in Playground.
How can we mark the examples that should not be played?
EDIT: I mean that those 64 examples [when ran] return errors unrelated to their code. Basically they are broken for the user. I am sure they confuse people here and there.
Ideally, every example should be runnable on the playground. Any that can possibly be rewritten to be runnable should be, of course.
Since this is playground specific, it shouldn't be in
That leaves a comment that
Posting the results of running all the examples against the playground. Most of them are
Some examples take too long, like time.Tick, but that should be okay when new version godoc will be deployed. It will show output even when the example has timed out.
Feel free to make any of those examples playground-friendly.