Skip to content

Commit

Permalink
fix: specialize discard for readerWithEOFContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Mar 10, 2022
1 parent 099ab3e commit 6eb0095
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ func discard(br io.Reader, n int) error {
}

switch r := br.(type) {
case *readerWithEOFContext:
err := discard(r.r, n)
if err == io.EOF && r.hasReadOnce {
err = io.ErrUnexpectedEOF
}
r.hasReadOnce = true
return err
case *bytes.Buffer:
buf := r.Next(n)
if len(buf) == 0 {
Expand Down

0 comments on commit 6eb0095

Please sign in to comment.