News for hackers. Stuff that matters.
Re:Errors are values by Arnavion on Monday January 12, 2015 @09:38PM (#8877795)
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 ) 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.

Re:Errors are values by enneff on Tuesday January 13, 2015 @05:57AM (#8879040)
> 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.