bytes.Buffer WriteAt

640 views
Skip to first unread message

Chris Hopkins

unread,
Apr 26, 2017, 5:21:10 AM4/26/17
to golang-nuts
Hi,
Random question:
I'm just starting implementing a file cache and using a bytes.Buffer in my testbench as a model of a perfect file.
One slight imperfection, the standard bytes.Buffer does not implement WriteAt which I find a little odd as it does implement ReadAt.
Now this is easy enough to work around, but I wondered if anyone knew the thinking behind it? Is it just no-one has bothered implementing it yet (I find this surprising) or am I missing something subtle here? If no-one has bothered implementing it, should I be publishing my workaround for future inclusion?

Background:
All the caches I've found so far seem based around http. Whereas I'm dealing with a large (pair of) file(s) that I expect to be accessing a small portion of, so a per file cache that caches read and write accesses seems like a really obvious thing to use. However I cannot find anyone else having written something similar. I guess people are just relying on the file system to do this for them.

Thanks

Chris


Chris Hopkins

unread,
Apr 26, 2017, 5:40:02 AM4/26/17
to golang-nuts
Apologies for replying to myself.
Digging into the source it looks like I had misunderstood the purpose/functionality of bytes.Buffer.
Sorry. Please ignore/delete the question.

Jan Mercl

unread,
Apr 26, 2017, 5:57:00 AM4/26/17
to Chris Hopkins, golang-nuts
On Wed, Apr 26, 2017 at 11:21 AM Chris Hopkins <cbeho...@gmail.com> wrote:

> However I cannot find anyone else having written something similar.

A file cache is just above it. Not importable so you need to copy/paste any code if you want to play with it.



--

-j

Reply all
Reply to author
Forward
0 new messages