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
proposal: io: add NewReaderAt #58679
Comments
The docs for
I don't think that there's any way to preserve that property using an implementation that's calling |
That constraint is clearly violated. |
I think that one's slightly less clear, actually, since the returned |
Since we have the lock on it, and
Would this requirement be met if the original offset is put back? It could error, but we can bubble the error up. |
It appears that |
That is libc's
Technically no. Even though your |
Well, I'm not too concerned about this case, because it would be the caller's responsibility to ensure the appropriate concurrency control. The similar sort of expectations exists in say |
I don't believe this is a great idea. This implementation is suboptimal at best, in that it does not allow concurrent reads. If we make it io.NewReaderAt, people will use it without realizing they are getting a subpar implementation. |
This proposal has been added to the active column of the proposals project |
If it is up to the caller to not call read or seek on the underlying ReadSeeker then the implementation probably doesn't need to reset the position either and call this out in the docs like it does for io.MultiReader How many people would really need this implementation and is it worth it to have it upstreamed to go vs having people implement this as needed (eschewing concurrency and/or seeking concerns). |
This does allow for concurrent |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
io.ReadSeeker
can be adapted toio.ReaderAt
. Once you haveio.ReaderAt
, you can do useful things with it like constructingio.SectionReader
.I propose adding such an adapter to the
io
package, for example:Update: restore offset after read
Update: add more detail to explain the returned errors
Update: tweaked the godoc a little to increase clarity
The text was updated successfully, but these errors were encountered: