Re: [go-nuts] bufio.Writer's sticky errors & lost data

2018-09-20 Thread Dan Kortschak
I think here, writing your own buffer type would be the most sensible approach. On Wed, 2018-09-19 at 10:14 -0700, John Floren wrote: > What's the right way to handle this? Write our own bufio that lets us > reset  > the error and io.Writer while preserving unwritten data? -- You received this m

Re: [go-nuts] bufio.Writer's sticky errors & lost data

2018-09-20 Thread Peter Waller
On Thu, 20 Sep 2018 at 03:39, John Floren wrote: > What's the right way to handle this? Write our own bufio that lets us > reset the error and io.Writer while preserving unwritten data? > I'm not sure there is "one right way", but one possibility is to push the reliability layer one level down:

[go-nuts] bufio.Writer's sticky errors & lost data

2018-09-19 Thread John Floren
If bufio.Writer.Flush() ever sees an error, it sets b.err and will immediately return that error on any future calls to Flush: https://golang.org/src/bufio/bufio.go?s=14569:14599#L558 Writer.Reset(w io.Writer) will clear the error and set the bufio.Writer to use the new io.Writer given, but it