Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tour: Output doesn't work #52

Closed
meownoid opened this issue Jul 24, 2016 · 1 comment
Closed

tour: Output doesn't work #52

meownoid opened this issue Jul 24, 2016 · 1 comment

Comments

@meownoid
Copy link

Context: https://tour.golang.org/methods/23

I've solved methods/23 like this:

func (old_reader rot13Reader) Read(b []byte) (int, error) {
    const LEN int = 1024
    tmp_bytes := make([]byte, LEN)
    old_len, err := old_reader.r.Read(tmp_bytes)
    if err == nil {
        tmp_bytes = tmp_bytes[:old_len]
        rot13(tmp_bytes)
        return len(tmp_bytes), nil
    } else {
        return 0, err
    }
}

func main() {
    s := strings.NewReader("Lbh penpxrq gur pbqr!")
    r := rot13Reader{s}
    io.Copy(os.Stdout, &r)
}

where rot13 is correct, but I can't see any output, process just exits. Debug output just before return len(tmp_bytes), nil shows correct string.

@adg
Copy link
Contributor

adg commented Jul 25, 2016

Please ask about this on one of our discussion forums: https://golang.org/wiki/Questions

@adg adg closed this as completed Jul 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants