mirror of
https://github.com/restic/restic.git
synced 2026-09-02 10:47:14 +00:00
improve fprintf related error handling
This commit is contained in:
@@ -106,7 +106,7 @@ func runRESTServer(ctx context.Context, t testing.TB, dir, reqListenAddr string)
|
||||
matched = true
|
||||
}
|
||||
}
|
||||
fmt.Fprintln(os.Stdout, line) // print all output to console
|
||||
_, _ = fmt.Fprintln(os.Stdout, line) // print all output to console
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ func goroutineNum() int {
|
||||
runtime.Stack(b, false)
|
||||
var num int
|
||||
|
||||
fmt.Sscanf(string(b), "goroutine %d ", &num)
|
||||
_, _ = fmt.Sscanf(string(b), "goroutine %d ", &num)
|
||||
return num
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ func (rd *eofDetectReader) Close() error {
|
||||
msg += fmt.Sprintf(", body: %q", buf)
|
||||
}
|
||||
|
||||
fmt.Fprintln(os.Stderr, msg)
|
||||
_, _ = fmt.Fprintln(os.Stderr, msg)
|
||||
Log("%s: %+v", msg, errors.New("Close()"))
|
||||
}
|
||||
return rd.rd.Close()
|
||||
|
||||
@@ -212,7 +212,7 @@ func (t *Terminal) runWithoutStatus(ctx context.Context) {
|
||||
}
|
||||
|
||||
if _, err := io.WriteString(dst, msg.line); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
|
||||
_, _ = fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
|
||||
}
|
||||
|
||||
if flush == nil {
|
||||
@@ -220,16 +220,18 @@ func (t *Terminal) runWithoutStatus(ctx context.Context) {
|
||||
}
|
||||
|
||||
if err := flush(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "flush failed: %v\n", err)
|
||||
_, _ = fmt.Fprintf(os.Stderr, "flush failed: %v\n", err)
|
||||
}
|
||||
|
||||
case stat := <-t.status:
|
||||
for _, line := range stat.lines {
|
||||
// Ensure that each message ends with exactly one newline.
|
||||
fmt.Fprintln(t.wr, strings.TrimRight(line, "\n"))
|
||||
if _, err := fmt.Fprintln(t.wr, strings.TrimRight(line, "\n")); err != nil {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
|
||||
}
|
||||
}
|
||||
if err := t.wr.Flush(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "flush failed: %v\n", err)
|
||||
_, _ = fmt.Fprintf(os.Stderr, "flush failed: %v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user