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

proposal: io: provide adapter types for the fundamental interfaces of Reader/Writer/Closer #24370

Closed
nelz9999 opened this issue Mar 13, 2018 · 2 comments

Comments

@nelz9999
Copy link

I believe that adapter types like http.HandlerFunc are incredibly useful. In fact, they are so useful that I want to use them in many places. Frequently, I want to use adapter types to implement io.Reader and io.Writer (and sometimes even io.Closer) behaviors.

Yes, it's not much code to define those adapter types, but it's kind of annoying to have to re-write them in each project. I believe the community would be well-served if these adapter types were established right there in the standard library.

I originally came at this proposal from a code-first approach: https://go-review.googlesource.com/c/go/+/98519 / #24247. Within that PR I found that the io.TeeReader was ripe for re-implementation by an io.ReaderFunc, and in multi_test.go there's already a writerFunc defined that could be replace by a standard io.WriterFunc.

@gopherbot gopherbot added this to the Proposal milestone Mar 13, 2018
@yiyus
Copy link

yiyus commented Mar 13, 2018

A more general solution for Go 2 has been proposed in #21670

@ianlancetaylor
Copy link
Contributor

Deferring this proposal in favor of #21670.

@golang golang locked and limited conversation to collaborators Mar 19, 2019
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