func ExampleFork() { var o []byte var e error var wait func() ([]byte, error) if wait, e = exec.Fork(Script); e != nil { fmt.Printf("%v\n", e) } else { fmt.Println("waiting") if o, e = wait(); e != nil { fmt.Printf("%v", e) } fmt.Print(string(o)) } if wait, e = exec.Fork("asdf"); e != nil { fmt.Printf("%v\n", e) } else { fmt.Println("waiting") if o, e = wait(); e != nil { fmt.Printf("%v", e) } fmt.Print(string(o)) } // Output: // waiting // stdout: foo // stderr: bar // exec: "asdf": executable file not found in $PATH }
func ExampleFork_Slow() { var o []byte var e error var wait func() ([]byte, error) if wait, e = exec.Fork(SlowScript); e != nil { fmt.Printf("%v\n", e) } else { fmt.Println("waiting") if o, e = wait(); e != nil { fmt.Printf("%v", e) } fmt.Print(string(o)) } // Output: // waiting // stdout: foo // stderr: bar }