You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
The text was updated successfully, but these errors were encountered: