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: re-add SizedReaderAt #15822
Comments
@rsc Could you tag this as Unplanned or Go1.8 as needed? |
Added to Go 1.8, thanks. I certainly intended that we would discuss after Go 1.7. |
As far as I can tell, Sizer's original use came from os.FileInfo. Subsequent cases skipped the A few options I see (in decreasing order of personal preference): Function that produces a conventional SizeReaderAt from any StatReaderAtWe could provide a function like:
In this case, SizeReaderAt would just be This would allow an os.File to be used fairly conveniently as an os.SizeReaderAt without adding any methods to existing types. Implement Stat method on {bytes,strings}.Readerbytes.Reader and strings.Reader can be given a stat method which returns a mostly-stubbed os.FileInfo. This would make those types more file-like, but increase the complexity of the interfaces that would come out of this (io.StatReaderAt). A This would also make it easier for strings.Reader and other types to be used in implementing http.File and similar. Multiple incompatible interfaces for the same method nameAny code accepting a "Size" method should check for both
Alternatively, or in addition, a Make a new method, with a new name
Give os.File conventional Stat method, but also
|
@extemporalgenome I completely missed your excellent analysis here. Thanks for it! I would like to go with your first suggestion: But I believe it might also be an excellent example for the io.SizeReaderAt and doesn't need to become API at all. Anyway: Adding io.SiteReaderAt shouldn't be blocked by this. @rsc / @bradfitz Would you like me to send a CL re-adding the interface? Would you accept another CL adding a functionality similiar to NewSizeReaderAt in io as an example for using an os.File to create a io.SizeReaderAt? |
Of the approaches listed above, I gravitate most towards just adding a new method. Even then, I don't get warm feelings about expanding the API. The other approaches either lose type safety or couple |
Still don't see a compelling argument for this. This interface can be defined outside the standard library equally well as inside. I'd prefer to just close this, at least until we're rethinking io more generally. |
io.ReadSizedAt has been added after 3 years of discussion and removed within 3h in #15818
Let's re-evaluate it's usefulness and design here after Go-1.7 shipped.
Relates to #14889 and #7263
The text was updated successfully, but these errors were encountered: