Convert ExitStatus to use fn to get details

Instead of requiring callers to read the struct fields to check for an
error, provide the exit results via a function instead which is more
natural.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2017-08-21 21:28:37 -04:00
parent 026896ac4c
commit 6ab99edb71
10 changed files with 85 additions and 61 deletions

View File

@@ -188,10 +188,11 @@ To do this we will simply call `Kill` on the task after waiting a couple of seco
}
status := <-exitStatusC
if status.Err != nil {
return status.Err
code, exitedAt, err := status.Result()
if err != nil {
return err
}
fmt.Printf("redis-server exited with status: %d\n", status.Code)
fmt.Printf("redis-server exited with status: %d\n", code)
```
We wait on our exit status channel that we setup to ensure the task has fully exited and we get the exit status.
@@ -291,10 +292,11 @@ func redisExample() error {
// wait for the process to fully exit and print out the exit status
status := <-exitStatusC
if status.Err != nil {
code, _, err := status.Result()
if err != nil {
return err
}
fmt.Printf("redis-server exited with status: %d\n", status.Code)
fmt.Printf("redis-server exited with status: %d\n", code)
return nil
}