-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: Go 2: io: Let MultiWriter return a WriteCloser #28480
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
I've run into this type of problem in several different places before, and I think it's indicative of a more general problem with the interface system. One example that comes to mind is in the implementation of the scripting language I'm working on. There are a number of types that are used to wrap other types to provide extra functionality, such as a type Func interface { /* ... */ }
type Lenner interface { /* ... */ }
type Array []Func // Implements both Func and Lenner.
type ScopedFunc struct { Inner Func } // Implements Func.
var sf Func = &ScopedFunc{ Inner: Array{} }
// Users of sf have no way to cleanly get access to the Lenner functionality of sf.Inner's actual value. Maybe this is something that could be solved by generics. |
It's fairly easy to wrap See: https://play.golang.org/p/fbst3OOSVyk If you are doing this, you should probably also consider That said, a general rule for helpers like |
As noted in #27617 (comment):
|
There doesn't seem to be a good reason to change |
The MultiWriter in Go 1 ignores the Close part of WriteClosers. Can this be changed in Go 2 so that the returned writer is a WriteCloser which on Close checks for each given writer if it is a WriteCloser and then calls Close?
This bug is similar to issue #27617 (TeeReader & ReadCloser).
The text was updated successfully, but these errors were encountered: