Skip to content

os/exec: StdoutPipe example fails when run on golang.org #13693

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

Closed
stevekuznetsov opened this issue Dec 19, 2015 · 11 comments
Closed

os/exec: StdoutPipe example fails when run on golang.org #13693

stevekuznetsov opened this issue Dec 19, 2015 · 11 comments
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge
Milestone

Comments

@stevekuznetsov
Copy link

On the official doc, the example under func (*Cmd) StdoutPipe fails with error: 2009/11/10 23:00:00 exec: "echo": executable file not found in $PATH when run.

@ianlancetaylor ianlancetaylor changed the title [golang] [doc] os/exec.StdoutPipe example fails on the official Go documentation os/exec: StdoutPipe example fails on the official Go documentation Dec 19, 2015
@ianlancetaylor
Copy link
Contributor

What operating system are you using?

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Dec 19, 2015
@stevekuznetsov
Copy link
Author

I'm in Fedora 22 but to be clear this is the embedded example in the web page that fails, not me running anything locally.

@ianlancetaylor
Copy link
Contributor

Ah, I see. Yes, none of the os/exec examples will actually work in the limited environment of the Go playground. We should try to document that somehow.

@ianlancetaylor ianlancetaylor added the Documentation Issues describing a change to documentation. label Dec 19, 2015
@ianlancetaylor ianlancetaylor changed the title os/exec: StdoutPipe example fails on the official Go documentation os/exec: StdoutPipe example fails when run on golang.org Dec 19, 2015
@odeke-em
Copy link
Member

I have a few ideas to help solve this

  1. We can document this for each example ie
// Note: This example when run in the playground
// will fail because the playground is sandboxed/limited
// so shell utility lookups will fail.

2a) Easily detect when we are running on the playground like this

import "runtime"

func execPathsUnavailable() bool {
     // Shell lookups and utilities are
     // unavailable on the playground running nacl
     return runtime.GOOS == "nacl"
}

2b) A little more complex:

  • Use the execPathsUnavailable() when extracting each example in exec/ detect and inject that comment in (1) before the body of each example.

Please let me know what you think would be a better option. Thanks.

@minux
Copy link
Member

minux commented Dec 20, 2015 via email

@stevekuznetsov
Copy link
Author

Could the 'run' button for the examples be removed or disabled?

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/18035 mentions this issue.

@bradfitz
Copy link
Contributor

@stevekuznetsov, yes, that's probably the right answer.

If we don't want to invent new annotation syntax, we could even just have a blacklist of code samples in hard-coded in cmd/godoc. If an example is on the blacklist then it'd get to Run button.

@minux
Copy link
Member

minux commented Dec 21, 2015 via email

@rsc
Copy link
Contributor

rsc commented Jan 6, 2016

If you're running your own godoc then the example runs fine, right?

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/18315 mentions this issue.

@rsc rsc closed this as completed in 901810a Jan 6, 2016
@golang golang locked and limited conversation to collaborators Jan 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

7 participants