Skip to content
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

io.ErrUnexpectedEOF should be returned instead of io.EOF when only partial data is present #398

Closed
extemporalgenome opened this issue Jul 7, 2023 · 0 comments

Comments

@extemporalgenome
Copy link
Contributor

codec returns io.EOF upon receiving truncated/incomplete data:

https://go.dev/play/p/retXRYuAszH

The documentation for io.EOF specifically indicates it should be used for graceful end-of-stream operations, and that io.ErrUnexpectedEOF should be used when more data was expected.

As such, I'd hope/expect the above playground link to print "unexpected EOF" rather than just "EOF".

This would allow me to distinguish between, for example, streamed reads where there is literally no more data available (we hit EOF before reading any bytes), versus a case where we read some bytes, but could not successfully parse the value.

@extemporalgenome extemporalgenome changed the title io.ErrUnexpectedEOF should be returned instead of io.EOF when only partial data is present io.ErrUnexpectedEOF should be returned instead of io.EOF when only partial data is present Jul 7, 2023
@ugorji ugorji closed this as completed in 43b79bf Nov 28, 2023
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

1 participant