Skip to content

Commit

Permalink
progressbar: Print to os.Stdout (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshineplan authored Sep 30, 2024
1 parent dd16e6e commit 32d82c6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions progressbar/progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ func (pb *ProgressBar) print(f format) {

width := buf.Len()
if width < pb.lastWidth {
io.WriteString(os.Stderr,
io.WriteString(os.Stdout,
fmt.Sprintf("\r%s\r%s", strings.Repeat(" ", pb.lastWidth), buf.Bytes()))
} else {
io.WriteString(os.Stderr, "\r\r"+buf.String())
io.WriteString(os.Stdout, "\r\r"+buf.String())
}

pb.lastWidth = width
Expand Down Expand Up @@ -236,13 +236,13 @@ func (pb *ProgressBar) startCount() {
f.Left = "Complete"

pb.print(f)
io.WriteString(os.Stderr, "\n")
io.WriteString(os.Stdout, "\n")

close(pb.done)
return
}
case <-pb.ctx.Done():
io.WriteString(os.Stderr, "\nCancelled\n")
io.WriteString(os.Stdout, "\nCancelled\n")
return
}
}
Expand Down

0 comments on commit 32d82c6

Please sign in to comment.