github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/lib/readers/readfill.go (about) 1 package readers 2 3 import "io" 4 5 // ReadFill reads as much data from r into buf as it can 6 // 7 // It reads until the buffer is full or r.Read returned an error. 8 // 9 // This is io.ReadFull but when you just want as much data as 10 // possible, not an exact size of block. 11 func ReadFill(r io.Reader, buf []byte) (n int, err error) { 12 var nn int 13 for n < len(buf) && err == nil { 14 nn, err = r.Read(buf[n:]) 15 n += nn 16 } 17 return n, err 18 }