1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Use errcheck to find unhandled errors (#795)

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2019-12-17 08:26:16 -08:00
committed by GitHub
parent 04ff03ab1c
commit cde904ff08
44 changed files with 250 additions and 97 deletions

View File

@@ -79,7 +79,7 @@ func (widget *Widget) Write(p []byte) (n int, err error) {
// Remove lines that exceed maxLines
lines := widget.countLines()
if lines > widget.settings.maxLines {
widget.drainLines(lines - widget.settings.maxLines)
err = widget.drainLines(lines - widget.settings.maxLines)
}
return n, err
@@ -93,10 +93,15 @@ func (widget *Widget) countLines() int {
}
// drainLines removed the first n lines from the buffer
func (widget *Widget) drainLines(n int) {
func (widget *Widget) drainLines(n int) error {
for i := 0; i < n; i++ {
widget.buffer.ReadBytes('\n')
_, err := widget.buffer.ReadBytes('\n')
if err != nil {
return err
}
}
return nil
}
func (widget *Widget) environment() []string {