1
0
gotour-notes/exercises/07-rot13/go.go
2012-08-28 22:37:55 -06:00

28 lines
377 B
Go

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)
}