3 ms·
That second-last example with errWriter destroys safety AFAICT, since it requires the user to remember to check for ew.err to see if the whole sequence of opera
by Arnavion 12y ago
That second-last example with errWriter destroys safety AFAICT, since it requires the user to remember to check for ew.err to see if the whole sequence of operations actually succeeded or not.
Atleast the last example with flush returning the error made sense, since that's an explicit "commit" operation that the user must call for correctness. However not every series of operations has a final commit operation, so this technique is unsafe in general.
(In fact even flush might be optional? I didn't check the docs.)
Edit: The docs for flush say nothing, but the docs for the Writer interface itself ( http://golang.org/pkg/bufio/#Writer http://golang.org/pkg/bufio/#Writer ) do:
> After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer.
- enneff 12y ago> That second-last example with errWriter destroys safety AFAICT It is possible to make mistakes. Go isn't the kind of language that forces you to be safe and do the right thing all the time. Like all languages, it makes tradeoffs.