28 lines
377 B
Go
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)
|
||
|
}
|