go - golang: cmd.Exec(): How I can read non-buffered stdout of apps? -


so have simple app starts other apps , reads output.

package main  import (     "bufio"     "io"     "log"     "os/exec"     "time" )  func main() {     cmd := exec.command("perl", "-e", "my $x = 0; while (1) { print ++$x.qx'date'; sleep 1; }")     stdout, _ := cmd.stdoutpipe()     stderr, _ := cmd.stderrpipe()      in := bufio.newreadersize(io.multireader(stdout, stderr), 100)     cmd.start()     defer cmd.wait()     {         log.printf("....")         time.sleep(1 * time.second)         l, _ := in.readstring('\n')         log.printf(string(l))     } } 

the point of real app read output of running process , parse it.. doesn't works real apps don't explicitly sync/flush stdout (it takes ~60 lines of iperf output before starting printing).

what efficient way read output byte-by-byte?


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -