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: WriteFull #9096

Closed
bradfitz opened this issue Nov 13, 2014 · 2 comments
Closed

io: WriteFull #9096

bradfitz opened this issue Nov 13, 2014 · 2 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

I'd like io.WriteFull, to mirror io.ReadFull.

WriteFull would be a tiny wrapper that just validated a io.Writer implementation's
return values:

   // WriteFull writes p to w. It returns either the Writer's error,
   // or ErrShortWrite if the writer returned a nil error and didn't write enough.
   func WriteFull(w io.Writer, p []byte) error {
         n, err := w.Write(p)
         if err == nil && n != len(p) { 
            err = ErrShortWrite
         }
         return err
   }

Doing this all the time defensively is tedious.
@rsc
Copy link
Contributor

rsc commented Nov 13, 2014

Comment 1:

I would really rather not. ReadFull exists because Read is *allowed* to return less than
was asked without an error. Write is not. I don't want to encourage people to think that
buggy Writers are okay by introducing a buggy Writer fixer.

@bradfitz
Copy link
Contributor Author

Comment 2:

Fair point.

Status changed to Retracted.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 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