Forráskód Böngészése

Comment CmdStream a little bit to facilitate future fixes and contributions

Solomon Hykes 12 éve
szülő
commit
6ede6bc8f2
1 módosított fájl, 3 hozzáadás és 0 törlés
  1. 3 0
      archive.go

+ 3 - 0
archive.go

@@ -56,6 +56,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
 	}
 	}
 	pipeR, pipeW := io.Pipe()
 	pipeR, pipeW := io.Pipe()
 	errChan := make(chan []byte)
 	errChan := make(chan []byte)
+	// Collect stderr, we will use it in case of an error
 	go func() {
 	go func() {
 		errText, e := ioutil.ReadAll(stderr)
 		errText, e := ioutil.ReadAll(stderr)
 		if e != nil {
 		if e != nil {
@@ -63,6 +64,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
 		}
 		}
 		errChan <- errText
 		errChan <- errText
 	}()
 	}()
+	// Copy stdout to the returned pipe
 	go func() {
 	go func() {
 		_, err := io.Copy(pipeW, stdout)
 		_, err := io.Copy(pipeW, stdout)
 		if err != nil {
 		if err != nil {
@@ -75,6 +77,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
 			pipeW.Close()
 			pipeW.Close()
 		}
 		}
 	}()
 	}()
+	// Run the command and return the pipe
 	if err := cmd.Start(); err != nil {
 	if err := cmd.Start(); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}