Notice the logic in (*bytes.Buffer).grow which will throw away already read
data, specifically in the case n <= c/2--m.

On Mon, Mar 25, 2019 at 9:57 AM fREW Schmidt <fri...@gmail.com> wrote:

> Oh thanks, I'll switch my code to reader, though as far as I can tell,
> bytes.Buffer doesn't discard already read data, it merely sets the
> (private) offset.  Maybe I just got luck though.
>
> Thanks again!
>
> On Mon, Mar 25, 2019 at 08:54:43AM +0000, roger peppe wrote:
> > The reason bytes.Buffer doesn't implement io.ReaderAt is that it doesn't
> > keep bytes in the buffer that have been read, so it's not possible to
> > implement that method.
> >
> > You can use bytes.Reader instead, which does implement io.ReaderAt and
> > io.Seeker.
> > To make a bytes.Reader from a bytes.Buffer, you can do
> > `bytes.NewReader(buf.Bytes())`.
> >
> >   hope this helps,
> >     rog.
> >
> > On Mon, 25 Mar 2019 at 06:06, <fri...@gmail.com> wrote:
> >
> > > Is there a reason I shouldn't submit a PR for bytes.Buffer.ReadAt?  It
> > > would at least help for some in memory tests.
> > >
> > > --
> > > Thanks,
> > > fREW
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "golang-nuts" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an
> > > email to golang-nuts+unsubscr...@googlegroups.com.
> > > For more options, visit https://groups.google.com/d/optout.
> > >
>
> --
> fREW Schmidt
> https://blog.afoolishmanifesto.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to