msgpack
msgpack copied to clipboard
add Decoder to read stream of messages
I am trying to read multiple messages appended to a file. This PR adds a poor mans version of a decoder for an io.Reader. Poor man, because it reads the full file in memory, which is good enough for my use case. I also changed the fmt.Errorf("data is empty") error to an io.EOF erro, which is more idiomatic go. Let me know if I should leave that out of this PR.
Hi.
I don't understand the intention of the PR, but I thought that if you want io.EOF, you should convert it when a decoding error happens.
see below.
// example
err := msgpack.Unmarshal(data, v)
if err.Error() == "data is empty" {
return io.EOF // convert or wrap
}
The idea is to be able to append msgpack records to a file. so you don't know how many records you get in advance.