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: io: there should be a multicloser #20136
Comments
Where would this be used? Generally we don't add things to the standard library unless they're common. See also: https://golang.org/doc/faq#x_in_std |
I would imagine this would get somewhere around the same amount of usage as a MultiWriter or MultiReader (which I can't say I've ever had a reason to use myself lol). |
@bradfitz But the point of this proposal is to complete the functionality of src/io/multi.go. In my mind it feels like it is missing. |
Yes, but where concretely? Could you find places in the standard library where code would be simplified by using this. In previous proposals where things are added to the standard library, the commit or the immediately following one updates the standard library to use the new feature. For instance, when I added Where would you use this?
That by itself doesn't meet the bar for standard library inclusion, especially this late in the game. It needs to be simplify existing code. |
@bradfitz |
Apologies for bumping this, but it's something I was looking for today. I would like to be able to close a MultiWriter and close all of the underlying io.CloseWriters. |
Just ended up in this thread again after hitting a need for this in an unrelated project. |
@SirCmpwn I don't think what you are asking for (closing an |
An |
Yes. I guess I'm confused. What are you asking for? |
|
Thanks, but I don't think we're going to do that, per @bradfitz's comment above. they can be written in a third party library just as effectively. |
I don't agree with @bradfitz's argument. Is the purpose of the standard library to serve itself? Of course not. If the use case for users of the standard library is compelling, then the standard library should be updated even if the features don't see internal use within the standard library. |
But this is the kind of functionality that can easily be written outside of the standard library. For this kind of thing, that is the place to start. Then if it proves to be popular, it can be brought in. |
I am familiar with that policy, and in most cases I would agree. But this is a case where the new feature is simple and addresses a defect in the stdlib - that we have a MultiWriter but not the equivalents for Closer and WriteCloser doesn't make sense. It's like only a third of the work was done, not like an entirely new feature is being proposed. |
I propose there be a multi-closer like struct inside of io/multi.go. The purpose would be that multiple close objects could be returned under one. Since there are already multi objects, (ie: reader/writer), it makes sense to me to also include multistructs for other things as well, including io.closer.
https://go-review.googlesource.com/c/41814/
The text was updated successfully, but these errors were encountered: