Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-10 Thread Michael Jones
Philosophically On Wed, Jun 10, 2020 at 11:26 AM Michael Jones wrote: > Philosophy, this is one of the Go library’s most beautiful designs. It > allows the one in charge—the program you write—to say what should happen, > while allowing everything subordinate to be guided on how it should happen.

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-10 Thread Michael Jones
Philosophy, this is one of the Go library’s most beautiful designs. It allows the one in charge—the program you write—to say what should happen, while allowing everything subordinate to be guided on how it should happen. This allows code to be adaptive to device optimal read sizes, network happens

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-10 Thread Ronny Bangsund
Reading in small chunks is handy for progress displays too. -- 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. To view this

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-09 Thread Amit Lavon
Interesting points. So I guess ReadFull can be suitable for the consuming end of those bytes. Thank you! On Tue, Jun 9, 2020 at 11:40 PM Brian Candler wrote: > On Tuesday, 9 June 2020 17:53:07 UTC+1, Amit Lavon wrote: >> >> Why would I ever use Reader.Read rather than ReadFull? >> >> > Because

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-09 Thread Brian Candler
On Tuesday, 9 June 2020 17:53:07 UTC+1, Amit Lavon wrote: > > Why would I ever use Reader.Read rather than ReadFull? > > Because it's often more efficient to process data in the "natural" chunks it comes in, rather than packing it out to fit a particular buffer size - in which case the final read

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-09 Thread Sam Whited
Read lets you build pipelines, it involves fewer expensive allocations (ie. you might not want to use ReadFull in the hot path of an important project), you could use read to read into a slice at different points, or not read the entirety of an expensive document into memory all at once, you can im

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-09 Thread Amit Lavon
Thank you!! io.ReadFull is just what I needed (and what I actually expected from Reader.Read). Why would I ever use Reader.Read rather than ReadFull? On Tue, Jun 9, 2020 at 6:11 PM Brian Candler wrote: > There is io.ReadFull if you want to > read as much as