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

bytes: Reader.WriteTo returns EOF incorrectly #4421

Closed
rsc opened this issue Nov 21, 2012 · 3 comments
Closed

bytes: Reader.WriteTo returns EOF incorrectly #4421

rsc opened this issue Nov 21, 2012 · 3 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Nov 21, 2012

// WriteTo implements the io.WriterTo interface.
func (r *Reader) WriteTo(w io.Writer) (n int64, err error) {
    r.prevRune = -1
    if r.i >= len(r.s) {
        return 0, io.EOF
    }

The io.EOF should be nil. This breaks:

package main

import (
    "bytes"
    "log"
    "os/exec"
)

func main() {
    cmd := exec.Command("cat")
    cmd.Stdin = bytes.NewReader(nil)
    err := cmd.Run()
    if err != nil {
        log.Fatal(err)
    }
}

Obviously there are simpler tests.
@bradfitz
Copy link
Contributor

Comment 1:

Btw, this isn't related to issue #4403.  I changed this line to a panic and it didn't
panic.

@bradfitz
Copy link
Contributor

Comment 2:

Sent http://golang.org/cl/6855083

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

Comment 3:

This issue was closed by revision c8fa7dc.

Status changed to Fixed.

@rsc rsc added fixed labels Nov 25, 2012
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants