code: func cmdStream(cmd *exec.Cmd, input io.Reader) (io.ReadCloser, error) {
  	cmd.Stdin = input
  	pipeR, pipeW := io.Pipe()
  	cmd.Stdout = pipeW
  	var errBuf bytes.Buffer
  	cmd.Stderr = &errBuf
  
  	// Run the command and return the pipe
  	if err := cmd.Start(); err != nil {
  		return nil, err
  	}
  
  	// Copy stdout to the returned pipe
  	go func() {
  		if err := cmd.Wait(); err != nil {
  			pipeW.CloseWithError(fmt.Errorf("%s: %s", err, errBuf.String()))
  		} else {
  			pipeW.Close()
  		}
  	}()
  
  	return pipeR, nil
  }
docs: // cmdStream executes a command, and returns its stdout as a stream.
  // If the command fails to run or doesn't complete successfully, an error
  // will be returned, including anything written on stderr.