Why does this code create Reader from Reader?

Why does this code need buffio.NewReader(…) ?

NewReader() from strings allready returns a pointer to Reader interface, is not it?

 in := bufio.NewReader(strings.NewReader(testFail))
 out := new(bytes.Buffer)
 err := uniq(in, out) // func uniq(input io.Reader, output io.Writer) error

Hi, cinematik, I can’t think of a reason to do this. A bufio.Reader might improve performance when the Reader it receives is from secondary storage or a network but I don’t see why you’d buffer reading from a string. Did this code used to receive a file or something and was changed to use a strings.Reader?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.