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

proposal: archive/zip: return io.ReaderAt in "func (f *File) OpenRaw()" #65497

Closed
je4 opened this issue Feb 3, 2024 · 1 comment
Closed

proposal: archive/zip: return io.ReaderAt in "func (f *File) OpenRaw()" #65497

je4 opened this issue Feb 3, 2024 · 1 comment
Labels
Milestone

Comments

@je4
Copy link

je4 commented Feb 3, 2024

Proposal Details

The archive/zip library allows uncompressed files to be saved in a zip file. This allows, for example, another zip file to be stored uncompressed in a zip file. When reading the file, it is now possible to open this ZIP file via File.OpenRaw(). However, as only the type io.Reader is returned here, it cannot be opened with zip.NewReader(). Internally, File.OpenRaw() already uses the ReaderAt type so that the returned io.Reader can be casted to io.ReaderAt. However, as this is not sustainable, it would be better if io.ReaderAt could be returned directly.

Example: https://go.dev/play/p/DlP3vqHtHY3

@je4 je4 added the Proposal label Feb 3, 2024
@gopherbot gopherbot added this to the Proposal milestone Feb 3, 2024
@ianlancetaylor
Copy link
Contributor

Sadly, it is too late to make this change. It would break the Go 1 compatibility guarantee.

As you suggest, you can use a type assertion to get the io.ReaderAt. If you want to future-proof the code, the fallback would be to io.ReadAll the contents and use that.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants