1
0
gotour-notes/exercises/07-rot13/go.go

28 lines
377 B
Go
Raw Normal View History

2012-08-28 21:37:55 -07:00
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)
}