Print the byte unit once in the summary line (closes #17)
check / check (push) Successful in 3m2s

formatBytes already ends in a unit, so the summary line read "9 B
bytes" or "1.0 KiB bytes". The format string in Stats.Print no longer
adds the word "bytes".

Print now takes the io.Writer to print to; its callers pass os.Stderr,
and the new test passes a buffer to read the line for one small and
one large byte count.

Model: opus-5-5
This commit is contained in:
2026-10-06 06:00:11 +00:00
parent c4b50e2b55
commit 3f9f150736
3 changed files with 33 additions and 6 deletions
+6 -6
View File
@@ -71,13 +71,13 @@ func (s *Stats) Duration() time.Duration {
return time.Since(s.StartTime)
}
func (s *Stats) Print(opts *options, operation string) {
func (s *Stats) Print(w io.Writer, opts *options, operation string) {
if opts.quiet {
return
}
fmt.Fprintf(os.Stderr,
"\n%s complete: %d files processed, %d skipped, %d failed, %s bytes in %s\n",
_, _ = fmt.Fprintf(w,
"\n%s complete: %d files processed, %d skipped, %d failed, %s in %s\n",
operation,
s.FilesProcessed,
s.FilesSkipped,
@@ -227,7 +227,7 @@ func runOverPaths(
}
finishBar(bar)
stats.Print(opts, op)
stats.Print(os.Stderr, opts, op)
return nil
}
@@ -481,7 +481,7 @@ func runCheck(opts *options, args []string, cont bool) error {
if perr != nil {
if !cont {
finishBar(bar)
stats.Print(opts, "check")
stats.Print(os.Stderr, opts, "check")
return perr
}
@@ -491,7 +491,7 @@ func runCheck(opts *options, args []string, cont bool) error {
}
finishBar(bar)
stats.Print(opts, "check")
stats.Print(os.Stderr, opts, "check")
return finalErr
}