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

net/http: use of Write method on Request/Response/Header is confusing #19104

Closed
mvdan opened this issue Feb 15, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@mvdan
Copy link
Member

commented Feb 15, 2017

I think the choice of Write as the method name for writing to an io.Writer in wire format is poor. Write is a well known method name coming from the io.Writer interface, so it can be confused with it.

But worse than that, while Write([]byte) error modifies the receiver, Write(io.Writer) error modifies the argument.

I understand that the signatures are different, but if I'm quickly reading code I want to be able to understand what's going on without keeping track of types and signtures. Right now, if I see this line, it's very hard to know which of the two it is without reading more code and some light investigation:

r.Write(buf)

I think a better name would be WriteTo or WriteToWire. Suggestions welcome.

This can't be done in Go 1.x, so marking as Go2.

@mvdan mvdan added the Go2 label Feb 15, 2017

@bradfitz bradfitz closed this Feb 15, 2017

@mvdan

This comment has been minimized.

Copy link
Member Author

commented Feb 15, 2017

@bradfitz reason behind closing?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Feb 15, 2017

Because it's Go2. We know where to find Go2 stuff later. We won't be searching for "is:open label:Go2" later.

I also don't want to encourage people to file Go2 bugs about everything they don't like. Hidden away is fine.

@golang golang locked and limited conversation to collaborators Feb 15, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.