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 implement buffering on top of it, etc.
It's probably pretty rare that you actually want to use ReadFull, or at
least, I don't find myself reaching for it very often.
—Sam
On Tue, Jun 9, 2020, at 12:51, Amit Lavon wrote:
> 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
> <
b.ca...@pobox.com> wrote:
> > There is io.ReadFull <
https://golang.org/pkg/io/#ReadFull> if you
> > There is ioutil.ReadAll <
https://golang.org/pkg/io/ioutil/#ReadAll>
> > <
https://groups.google.com/d/msgid/golang-nuts/8ff054df-218c-4d52-8984-83b1c4444ed9o%40googlegroups.com?utm_medium=email&utm_source=footer>
> > .
>
> --
> 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+uns...@googlegroups.com. To view this discussion on the web
> visit
>
https://groups.google.com/d/msgid/golang-nuts/CAPTkDQVudE24DF6tWBO6yFTyF4TgZOopEfjnqZXLhVphp8SBwQ%40mail.gmail.com
> <
https://groups.google.com/d/msgid/golang-nuts/CAPTkDQVudE24DF6tWBO6yFTyF4TgZOopEfjnqZXLhVphp8SBwQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
--
Sam Whited