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

Should byteReader.extend account for empty reads? #17

Open
mna opened this issue Nov 24, 2023 · 0 comments
Open

Should byteReader.extend account for empty reads? #17

mna opened this issue Nov 24, 2023 · 0 comments

Comments

@mna
Copy link

mna commented Nov 24, 2023

Hello,

I'm looking to use something like the byteReader approach for one of my projects, and looking at it a bit more closely, I see that the json package considers a call of byteReader.extend that returns 0 as EOF (see the call in Scanner.Next, for example). The documentation of Scanner.Next mentions that "If the stream is at its end, or an error has occurred, Next returns a zero length []byte slice."

However, it is possible that the underlying io.Reader returns 0, nil as a call to Read, which indicates that no data is available but no error was encountered, in which case a number of retries should probably happen in byteReader.extend? I'm thinking something like what is done in bufio.Reader.fill.

It's possible that I'm missing something and the io.Reader in byteReader is always expected to be of a certain type that guarantees no empty reads (without error) or something like that.

Thanks,
Martin

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