From 2b7a08c3c79030b07290f2f71033443273f8a5f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Carvalho?= Date: Sat, 15 Jul 2017 14:42:31 -0300 Subject: [PATCH] os/exec: add example for Cmd.Run Change-Id: Ic47198bc8bf5baabfcf4d0599825eab30d7b126c Reviewed-on: https://go-review.googlesource.com/48853 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/os/exec/example_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/os/exec/example_test.go b/src/os/exec/example_test.go index b70b990325..62866fa710 100644 --- a/src/os/exec/example_test.go +++ b/src/os/exec/example_test.go @@ -57,6 +57,13 @@ func ExampleCmd_Output() { fmt.Printf("The date is %s\n", out) } +func ExampleCmd_Run() { + cmd := exec.Command("sleep", "1") + log.Printf("Running command and waiting for it to finish...") + err := cmd.Run() + log.Printf("Command finished with error: %v", err) +} + func ExampleCmd_Start() { cmd := exec.Command("sleep", "5") err := cmd.Start() -- 2.48.1