Browse code

Comment CmdStream a little bit to facilitate future fixes and contributions

Solomon Hykes authored on 2013/03/30 05:26:02
Showing 1 changed files
... ...
@@ -56,6 +56,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
56 56
 	}
57 57
 	pipeR, pipeW := io.Pipe()
58 58
 	errChan := make(chan []byte)
59
+	// Collect stderr, we will use it in case of an error
59 60
 	go func() {
60 61
 		errText, e := ioutil.ReadAll(stderr)
61 62
 		if e != nil {
... ...
@@ -63,6 +64,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
63 63
 		}
64 64
 		errChan <- errText
65 65
 	}()
66
+	// Copy stdout to the returned pipe
66 67
 	go func() {
67 68
 		_, err := io.Copy(pipeW, stdout)
68 69
 		if err != nil {
... ...
@@ -75,6 +77,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
75 75
 			pipeW.Close()
76 76
 		}
77 77
 	}()
78
+	// Run the command and return the pipe
78 79
 	if err := cmd.Start(); err != nil {
79 80
 		return nil, err
80 81
 	}