Skip to content

Commit

Permalink
feat: ignore io.EOF from io.ReadAtLeast
Browse files Browse the repository at this point in the history
See https://pkg.go.dev/io#ReadAtLeast

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Aug 10, 2024
1 parent bbdc417 commit 03a5b00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions errorlint/allowed.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func setDefaultAllowedErrors() {
{Err: "io.EOF", Fun: "(*io.SectionReader).Read"},
{Err: "io.EOF", Fun: "(*io.SectionReader).ReadAt"},
{Err: "io.ErrClosedPipe", Fun: "(*io.PipeWriter).Write"},
{Err: "io.EOF", Fun: "io.ReadAtLeast"},
{Err: "io.ErrShortBuffer", Fun: "io.ReadAtLeast"},
{Err: "io.ErrUnexpectedEOF", Fun: "io.ReadAtLeast"},
{Err: "io.EOF", Fun: "io.ReadFull"},
Expand Down
10 changes: 4 additions & 6 deletions errorlint/testdata/src/allowed/allowed.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ func IoPipeWriterWrite(w *io.PipeWriter) {
}
}

func IoReadAtLeast(r io.Reader) {
func IoReadAtLeast(r io.Reader) error {
var buf [4096]byte
_, err := io.ReadAtLeast(r, buf[:], 8192)
if err == io.ErrShortBuffer {
fmt.Println(err)
}
if err == io.ErrUnexpectedEOF {
fmt.Println(err)
if err == io.ErrShortBuffer || err == io.ErrUnexpectedEOF || err == io.EOF {
return err
}
return nil
}

func IoReadFull(r io.Reader) {
Expand Down

0 comments on commit 03a5b00

Please sign in to comment.