You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: