golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.06k stars 17.68k forks source link

proposal: io/io add a new API to copy io.reader #70315

Closed amone-bit closed 20 hours ago

amone-bit commented 20 hours ago

Proposal Details

Sometimes I need a same io.reader, I don't want to create twice or use io.teeReader to read full data to memory. Maybe add a new API to copy io.reader will be convenient.

gabyhelp commented 20 hours ago

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

amone-bit commented 20 hours ago

It seems a little different, I don't want to read all data to memory to avoid overload. The method in https://github.com/golang/go/issues/64274 buffer seems will be bigger, finally bigger than memory with the reader call Read().

seankhliao commented 20 hours ago

By definition, io.Readers are single use only. I don't see how this is feasible.