Re: [go-nuts] bytes.Buffer.ReadAt?

2019-03-25 Thread fREW Schmidt
Ah my stuff just never got that big.  Thank you!

On Mon, Mar 25, 2019 at 11:23:12AM -0400, Thomas Bushnell, BSG wrote:
> 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  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 +, 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,  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.
> >

-- 
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.


Re: [go-nuts] bytes.Buffer.ReadAt?

2019-03-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
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  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 +, 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,  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.


Re: [go-nuts] bytes.Buffer.ReadAt?

2019-03-25 Thread fREW Schmidt
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 +, 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,  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.


Re: [go-nuts] bytes.Buffer.ReadAt?

2019-03-25 Thread roger peppe
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,  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.
>

-- 
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.


[go-nuts] bytes.Buffer.ReadAt?

2019-03-25 Thread frioux
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.