Skip to content

Commit

Permalink
Don't use log.Print for writing to Stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
shackra committed Jan 2, 2025
1 parent 07ff8f6 commit 8b19aab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/uhttp/body_print.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package uhttp
// the behavior of `BaseHttpClient` with an unexported flag.

import (
"errors"
"fmt"
"io"
"log"
"os"
)

type printReader struct {
Expand All @@ -15,7 +17,10 @@ type printReader struct {
func (pr *printReader) Read(p []byte) (int, error) {
n, err := pr.reader.Read(p)
if n > 0 {
log.Print(string(p[:n]))
_, merr := fmt.Fprint(os.Stdout, string(p[:n]))
if merr != nil {
return -1, errors.Join(err, merr)
}
}

return n, err
Expand Down

0 comments on commit 8b19aab

Please sign in to comment.