I'm having some trouble with tour.golang.org/methods/23
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
}
func (r rot13Reader) Read(s []byte) (int, error) {
a, e := r.r.Read(s)
for i := 0; i < a; i++ {
if(s[i] >= 'a') {
s[i] = ((s[i] - 'a') + 13) % 26 + 'a'
}
if(s[i] >= 'A') {
s[i] = ((s[i] - 'A') + 13) % 26 + 'A'
}
}
return a, e
}
func main() {
s := strings.NewReader("Lbh penpxrq gur pbqr!")
r := rot13Reader{s}
io.Copy(os.Stdout, &r)
}
I'm adding then modding but the results don't quite look right after accounting for the gap between the ascii codes for lower and upper case
YHN VKTVDXW MAX VHWX!