Buffered writer
The bufio package lets you create a buffered writer so that you can work with a buffer in memory before writing it to disk. This is useful if you need to do a lot of manipulation on the data before writing it to disk to save time from disk IO. It is also useful if you only write one byte at a time and want to store a large number in a memory buffer before dumping it to file at once, otherwise you would be performing disk IO for every byte. This puts wear and tear on your disk as well as it slows down the process.
Buffered writers can be inspected to see how much unbuffered data it is currently storing and how much buffer space is remaining. A buffer can also be reset to undo any changes since the last flush. The buffers are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access