-
Notifications
You must be signed in to change notification settings - Fork 18.1k
proposal: compress: add Compress and Decompress convenience functions #16504
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
Comments
If we do this, we should use a |
Maybe things have changed, but I would expect pushback for sync.Pool use. |
Just like net/http has:
etc
Apologies if am preaching to the choir but it wasn't straight forward for me from your example if the convenience functions would be in the top level compress or in each package. |
@odeke-em, the suggestion in the original post is for exactly what you listed out. Thanks for the asking to clarify. |
If convenience functions are required for compression packages I suggest the alternatives:
These functions would have more use cases and are very easy to use with a bytes.Buffer or a bytes.Reader.
BTW Decompression doesn't need the Close call. It doesn't do anything useful. Depending on the compression package Close for a reader either sets the reader to closed or returns the last returned error if its not io.EOF. IMHO returning a io.ReadCloser for a decompressor is a design error. The bzip2 package does the right thing and returns only an io.Reader. |
Yeah, I don't think helpers which slurp everything to memory are helpful. You're compressing it in the first place because it's large, so pulling it all into memory when it's almost certainly large is not a good idea. I think the existing Reader- & Writer-based interfaces are the right answer. Maybe we just need more documentation? |
Sorry, going to close this one. We already have @ulikunitz's |
Uh oh!
There was an error while loading. Please reload this page.
Filing on behalf of an internal user, who requests that we add convenience wrappers of Compress and Decompress:
What are people's thoughts?
The text was updated successfully, but these errors were encountered: