os/exec: make the Cmd.Start example runnable in the playground
The Cmd.Start example runs sleep for five seconds, which exceeds the
playground execution timeout when the example is run from pkg.go.dev.
Use echo instead. This keeps the example focused on the Start and Wait
workflow while allowing it to complete within the playground timeout.
Fixes #80236
diff --git a/src/os/exec/example_test.go b/src/os/exec/example_test.go
index 150f5cf..725a391 100644
--- a/src/os/exec/example_test.go
+++ b/src/os/exec/example_test.go
@@ -63,7 +63,7 @@
}
func ExampleCmd_Start() {
- cmd := exec.Command("sleep", "5")
+ cmd := exec.Command("echo")
err := cmd.Start()
if err != nil {
log.Fatal(err)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
cmd := exec.Command("echo")Why don't we actually echo a value? "echo", "hello", "world"
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
Why don't we actually echo a value? "echo", "hello", "world"
Good point. Using echo with an actual value makes the example command more natural.
Thanks for the suggestion.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |