Skip to content

Commit

Permalink
use SyncPrintf after review
Browse files Browse the repository at this point in the history
  • Loading branch information
ivandeex committed May 29, 2021
1 parent 4709f06 commit 7fd943f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions fs/operations/check.go
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"context"
"fmt"
"io"
"os"
"regexp"
Expand Down Expand Up @@ -65,14 +64,10 @@ func (c *checkMarch) report(o fs.DirEntry, out io.Writer, sigil rune) {

func (c *checkMarch) reportFilename(filename string, out io.Writer, sigil rune) {
if out != nil {
c.ioMu.Lock()
_, _ = fmt.Fprintf(out, "%s\n", filename)
c.ioMu.Unlock()
syncFprintf(out, "%s\n", filename)
}
if c.opt.Combined != nil {
c.ioMu.Lock()
_, _ = fmt.Fprintf(c.opt.Combined, "%c %s\n", sigil, filename)
c.ioMu.Unlock()
syncFprintf(c.opt.Combined, "%c %s\n", sigil, filename)
}
}

Expand Down
2 changes: 1 addition & 1 deletion fs/operations/operations.go
Expand Up @@ -853,7 +853,7 @@ var SyncPrintf = func(format string, a ...interface{}) {
func syncFprintf(w io.Writer, format string, a ...interface{}) {
outMutex.Lock()
defer outMutex.Unlock()
if w == nil {
if w == nil || w == os.Stdout || w == os.Stderr {
SyncPrintf(format, a...)
} else {
_, _ = fmt.Fprintf(w, format, a...)
Expand Down

0 comments on commit 7fd943f

Please sign in to comment.