ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.87k stars 295 forks source link

codec: handle EOF on last non-zero byte read #54

Closed mattrichards closed 9 years ago

mattrichards commented 9 years ago

The io.Reader interface specifies that Read() may return io.EOF when it encounters the end of the stream, even if it returns some bytes. Handle this case in the decoder by setting the error to nil if it reads any bytes.

ugorji commented 9 years ago

I can't merge the PR because solution will not work well. We need to treat EOF specifically according to the way it is defined in the io library, ensuring that the number of requested bytes was read (completely).

I have included the fix in an upcoming update.

ugorji commented 9 years ago

Also, the tests need an overhaul. They work today, but the organization needs some thought. I don't want to accept PR's for them now.

ugorji commented 9 years ago

main issue with EOF logged as issue #58, and closed with commit 11c92bbf14fb06664d2a8ad2156de0ee58c51758