Seek in buffered reader

go

Solution

The purpose of `bufio` is to provide buffered I/O. Buffered I/O is intended for performance, not time travel.

You can just read your data into a byte slice, then use `bytes.Reader` to process it further.

Problem

I need to create a buffered reader of an existing child `io.Reader`, but that reader must support seeking in data already read and buffered from the child. So when `n` bytes were already read, I want to be able to reset the reader to offset `0` and read that chunk again. Unfortunately `bufio.Reader` doesn't support seeking. Is there a standard reader that supports this, or do I have to implement my own?

Original source