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

io: add WriteString support to io.MultiWriter #11805

Closed
josharian opened this issue Jul 21, 2015 · 4 comments
Closed

io: add WriteString support to io.MultiWriter #11805

josharian opened this issue Jul 21, 2015 · 4 comments
Milestone

Comments

@josharian
Copy link
Contributor

No API changes necessary.

Are there any other writers in the stdlib that should have WriteString implemented as well?

@cespare
Copy link
Contributor

cespare commented Jul 21, 2015

I must be missing something. io.MultiWriter returns an io.Writer, so you'd need an interface assertion to take advantage of this, correct? Is there some ReaderFrom-style optimization that I'm not aware of that this would enable?

@bradfitz bradfitz added this to the Go1.6 milestone Jul 21, 2015
@bradfitz bradfitz self-assigned this Jul 21, 2015
@bradfitz
Copy link
Contributor

CL https://golang.org/cl/12485 mentions this issue.

@josharian
Copy link
Contributor Author

@cespare io.WriteString checks whether the Writer implements WriteString. See http://golang.org/src/io/io.go?s=9776:9831#L268.

@bradfitz that was fast. :) I thought I was going to have more time to poke around and check the rest of the writers, particular net/http's default responseWriter.

@bradfitz
Copy link
Contributor

net/http's responseWriter already does WriteString:

func (w *response) Write(data []byte) (n int, err error) {
        return w.write(len(data), data, "")
}

func (w *response) WriteString(data string) (n int, err error) {
        return w.write(len(data), nil, data)
}

// either dataB or dataS is non-zero.                                                                                                                                       
func (w *response) write(lenData int, dataB []byte, dataS string) (n int, err error) {

@golang golang locked and limited conversation to collaborators Sep 4, 2016
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

4 participants