Skip to content

false positive on with err == io.EOF on *bytes.Reader #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trim21 opened this issue Jul 21, 2021 · 1 comment
Closed

false positive on with err == io.EOF on *bytes.Reader #13

trim21 opened this issue Jul 21, 2021 · 1 comment

Comments

@trim21
Copy link

trim21 commented Jul 21, 2021

this should be good:

type CompressedFile struct {
	reader             *bytes.Reader
	zipPath            string
}

func (c CompressedFile) Read(p []byte) (int, error) {
	n, err := c.reader.Read(p)
	if err == io.EOF { // report error here
		return n, io.EOF
	}

	return n, errors.Wrapf(err, "can't read from reader %s", c.zipPath)
}

( and yes, I know I should use io.Reader here instead of *bytes.Reader...

@trim21 trim21 changed the title false positive on with err == io.EOF on bytes.Reader false positive on with err == io.EOF on *bytes.Reader Jul 21, 2021
@polyfloyd
Copy link
Owner

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants