Golang bufio.NewReaderSize() function example

package bufio

NewReaderSize returns a new Reader whose buffer has at least the specified size. If the argument io.Reader is already a Reader with large enough size, it returns the underlying Reader.

Golang bufio.NewReaderSize() function example

 const chunksize = 8192 // we settle for 8KB
 readbuffer := bytes.NewBuffer([]byte("input string to be read into new buffer"))
 reader := bufio.NewReaderSize(readbuffer, chunksize) // you get to specify the size in bytes

Advertisement