The logic for io.ReadFull returns errors from the underlying io.Reader verbatim.
In the case where io.Reader returns io.ErrUnexpectedEOF, it is impossible for the caller of io.ReadFull to distinguish between whether:
- the underlying
io.Reader abruptly ended and is in a truncated state, or
- the underlying
io.Reader ended correctly and there is no more data.
To avoid this ambiguity, we should wrap any io.ErrUnexpectedEOF from the underlying io.Reader.
However, I suspect that this is a breaking change and the best that we can hope for is to just document this.
\cc @josharian @catzkorn
The logic for
io.ReadFullreturns errors from the underlyingio.Readerverbatim.In the case where
io.Readerreturnsio.ErrUnexpectedEOF, it is impossible for the caller ofio.ReadFullto distinguish between whether:io.Readerabruptly ended and is in a truncated state, orio.Readerended correctly and there is no more data.To avoid this ambiguity, we should wrap any
io.ErrUnexpectedEOFfrom the underlyingio.Reader.However, I suspect that this is a breaking change and the best that we can hope for is to just document this.
\cc @josharian @catzkorn