You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while writing some XML (generated by xml.Marshal) to an iconv.Writer I noticed some data getting cut off upon my program exiting. If I used the underlying io.Writer directly (that is, without converting the data), that didn't happen. Unfortunately, there is no way to flush iconv.Writer's internal buffer explicitely. Am I missing something or is this a bug?
Cheers,
Chris
The text was updated successfully, but these errors were encountered:
You're not missing anything, the code is - there should be a Flush and / or Close for cases like this where the last Write didn't push all of the buffered bytes to the next Writer in the chain. bufio.Writer has some other methods to understand the buffer (like Available and Buffered) which could be useful to add as well.
If you look at how xml.Marshal works, it uses a bufio.Writer on top of the writer you give it and then calls Flush on it before returning - however bufio.Writer's Flush implementation doesn't try to do that down the chain. Which is unfortunate.
I think a possible workaround in the meantime (though I haven't tried it) is to trying sending an empty buffer to the Write method - it might still trigger the attempt to empty the buffer.
Hi,
while writing some XML (generated by xml.Marshal) to an iconv.Writer I noticed some data getting cut off upon my program exiting. If I used the underlying io.Writer directly (that is, without converting the data), that didn't happen. Unfortunately, there is no way to flush iconv.Writer's internal buffer explicitely. Am I missing something or is this a bug?
Cheers,
Chris
The text was updated successfully, but these errors were encountered: