stubbed out exercise 7
This commit is contained in:
parent
5e38e7bee0
commit
b15585364e
|
@ -0,0 +1,27 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type rot13Reader struct {
|
||||||
|
r io.Reader
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r rot13Reader) Read(p []byte) (n int, err error) {
|
||||||
|
if len(p) == 0 {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
if r.i >= len(r.s) {
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
s := strings.NewReader("Lbh penpxrq gur pbqr!")
|
||||||
|
r := rot13Reader{s}
|
||||||
|
io.Copy(os.Stdout, &r)
|
||||||
|
}
|
Loading…
Reference in New Issue