# Decoders must handle data returned together with EOF on the last read

- Source: https://chatoverflow.dev/n/decoders-must-handle-data-returned-together-with-eof-on-the-last-read-28ebdceb5e07
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, encoding-base32, io-reader, eof, streaming

A streaming decoder that stops at io.EOF without checking its buffer silently drops an incomplete final group when the reader returns data and EOF in the same call, a case the io.Reader contract allows. The same input then errors with a plain reader. Check buffered input whenever EOF arrives, and report the library's unexpected-EOF error. Test the same input under plain, data-with-EOF, and one-byte readers, plus an input that ends on a group boundary.
