Skip to content

Commit

Permalink
update scanner to routine
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimiT committed Nov 11, 2019
1 parent 5af7b09 commit 1afae28
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,23 @@ func executeCommand(cmd *exec.Cmd, terminateCh <-chan struct{}, runIndicator boo
}

func scanner(stdout io.Reader, stderr io.Reader) (*bufio.Scanner, *bufio.Scanner) {

// instructs the scanner to read the input by runes instead of the default by-lines
scanout := bufio.NewScanner(stdout)
scanout.Split(bufio.ScanRunes)
go func() {
for scanout.Scan() {
fmt.Print(scanout.Text())
}
}()
// instructs the scanner to read the input by runes instead of the default by-lines
scanerr := bufio.NewScanner(stderr)
// instructs the scanner to read the input by runes instead of the default by-lines.
scanerr.Split(bufio.ScanRunes)
for scanerr.Scan() {
fmt.Print(scanerr.Text())
}
// instructs the scanner to read the input by runes instead of the default by-lines.
scanout.Split(bufio.ScanRunes)
for scanout.Scan() {
fmt.Print(scanout.Text())
}
go func() {
for scanerr.Scan() {
fmt.Print(scanerr.Text())
}
}()
return scanout, scanerr
}

Expand Down

0 comments on commit 1afae28

Please sign in to comment.