From 6ede6bc8f2c1cd465fd48120d42aa39853b51111 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Fri, 29 Mar 2013 13:26:02 -0700 Subject: [PATCH] Comment CmdStream a little bit to facilitate future fixes and contributions --- archive.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/archive.go b/archive.go index 8efbb6b828..0421c51768 100644 --- a/archive.go +++ b/archive.go @@ -56,6 +56,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) { } pipeR, pipeW := io.Pipe() errChan := make(chan []byte) + // Collect stderr, we will use it in case of an error go func() { errText, e := ioutil.ReadAll(stderr) if e != nil { @@ -63,6 +64,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) { } errChan <- errText }() + // Copy stdout to the returned pipe go func() { _, err := io.Copy(pipeW, stdout) if err != nil { @@ -75,6 +77,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) { pipeW.Close() } }() + // Run the command and return the pipe if err := cmd.Start(); err != nil { return nil, err }