compress/gzip: provide user access to size trailer (when possible) #32539
Labels
FeatureRequest
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
The current
gzip.Reader
reads and verifies the trailer crc and size at the end, but the user currently has no way of reading (to pre-allocate output resources) the size.How much appetite do we have for adding something like a
func ReadSize(io.ReadSeeker) (uint32, error)
utility to thecompress/gzip
package?For concreteness, a case that I really have in mind is decompression in Shopify/sarama, leading to dynamic
bytes.Buffer
reallocation growth underioutil.ReadAll
.Using that example, perhaps another / a better option would be something like
func Decode([]byte) ([]byte, error)
like both snappy and zstd provide?However there's some appeal to being able to do the classic "seek to the end, read the size, pre-allocate, seek back to 0 and start streaming" idiom...
The text was updated successfully, but these errors were encountered: