title: How to show output of command in stdout/stderr while also saving the output into a variable in Go?
body: <p>I think I'm on the right track but my solution just hangs and doesn't print anything to screen, what am I doing wrong here?</p>
  
  <pre><code>    r, w := io.Pipe()
      var stdout, stderr bytes.Buffer
      cmd.Stdout = w
      cmd.Stderr = &amp;stderr
      tstdout := io.TeeReader(r, os.Stdout)
      tstderr := io.TeeReader(r, os.Stderr)
      io.Copy(&amp;stdout, tstdout)
      io.Copy(&amp;stderr, tstderr)
  
      err := cmd.Run()
  
      res := processResult{
          stderr.String(),
          stdout.Bytes(),
      }
  </code></pre>