Skip to content

Commit

Permalink
fix: panic with csv and SQLite format
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Apr 18, 2024
1 parent fd7b9c1 commit 4a5584d
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions cmd/misspell/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ func main() {
log.Fatalf("Mode must be one of auto=guess, go=golang source, text=plain or markdown-like text")
}

// we can't just write to os.Stdout directly since we have multiple goroutine
// all writing at the same time causing broken output.
// Log is routine safe.
// we see it, so it doesn't use a prefix or include a time stamp.
switch {
case *quietFlag || *outFlag == os.DevNull:
stdout = log.New(io.Discard, "", 0)
case *outFlag == "/dev/stderr" || *outFlag == "stderr":
stdout = log.New(os.Stderr, "", 0)
case *outFlag == "/dev/stdout" || *outFlag == "stdout":
stdout = log.New(os.Stdout, "", 0)
case *outFlag == "" || *outFlag == "-":
stdout = log.New(os.Stdout, "", 0)
default:
fo, err := os.Create(*outFlag)
if err != nil {
log.Fatalf("unable to create outfile %q: %s", *outFlag, err)
}
defer fo.Close()
stdout = log.New(fo, "", 0)
}

//
// Custom output
//
Expand All @@ -200,28 +222,6 @@ func main() {
defaultRead = template.Must(template.New("defaultRead").Parse(defaultReadTmpl))
}

// we can't just write to os.Stdout directly since we have multiple goroutine
// all writing at the same time causing broken output.
// Log is routine safe.
// we see it, so it doesn't use a prefix or include a time stamp.
switch {
case *quietFlag || *outFlag == os.DevNull:
stdout = log.New(io.Discard, "", 0)
case *outFlag == "/dev/stderr" || *outFlag == "stderr":
stdout = log.New(os.Stderr, "", 0)
case *outFlag == "/dev/stdout" || *outFlag == "stdout":
stdout = log.New(os.Stdout, "", 0)
case *outFlag == "" || *outFlag == "-":
stdout = log.New(os.Stdout, "", 0)
default:
fo, err := os.Create(*outFlag)
if err != nil {
log.Fatalf("unable to create outfile %q: %s", *outFlag, err)
}
defer fo.Close()
stdout = log.New(fo, "", 0)
}

//
// Number of Workers / CPU to use
//
Expand Down

0 comments on commit 4a5584d

Please sign in to comment.