Skip to content

Commit

Permalink
reformat cmdline.CommandRealtimeStdout
Browse files Browse the repository at this point in the history
  • Loading branch information
qwenode committed Apr 11, 2024
1 parent f6a3684 commit 6862ee5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmdline/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmdline
import (
"bufio"
"github.com/qwenode/gogo/sanitize"
"io/ioutil"
"io"
"os/exec"
)

Expand Down Expand Up @@ -34,15 +34,15 @@ func CommandRealtimeStdout(fn commandStdoutFunc, name string, arg ...string) boo
defer pipe.Close()
defer stderrPipe.Close()
if err := command.Start(); err != nil {
all, _ := ioutil.ReadAll(stderrPipe)
all, _ := io.ReadAll(stderrPipe)
return fn(string(all), sanitize.Int(string(all)), true)
}
reader := bufio.NewReader(pipe)
r := true
for {
readString, err := reader.ReadString('\n')
if err != nil {
all, _ := ioutil.ReadAll(stderrPipe)
all, _ := io.ReadAll(stderrPipe)
r = fn(string(all), sanitize.Int(string(all)), true)
break
}
Expand Down

0 comments on commit 6862ee5

Please sign in to comment.