A common pattern is an io.Reader that wraps another io.Reader, modifying the stream in some way.
For example, the gzip.NewReader function takes an io.Reader (a stream of compressed data) and returns a *gzip.Reader that also implements io.Reader (a stream of the decompressed data).
Implement a rot13Reader that implements io.Reader and reads from an io.Reader, modifying the stream by applying the rot13 substitution cipher to all alphabetical characters.
The rot13Reader type is provided for you. Make it an io.Reader by implementing its Read method.
Junilu Lacar wrote:In this exercise, it's also important to understand how line 29 works.
Read https://golang.org/pkg/io/#Copy carefully so you know what to expect in your Read function and you can make it live up to what io.Copy expects from it. The way you've written it, your Read implementation is doing some surprising things, things that io.Copy doesn't expect, so naturally it's also giving some surprising results.
Kevin Simonson wrote:Can you tell me why prevailing style frowns on writing the call to rr.read() with a space before its parameter?