Closed MarcoPolo closed 2 years ago
heh this is actually also addressed in: https://github.com/whyrusleeping/cbor-gen/pull/44/files#diff-8b7f25bac2ae04c2ce2abb628c6aa28103fd113103a62f3e9d232fa995684915R291-R300
Closing in favor of https://github.com/whyrusleeping/cbor-gen/pull/60
readByteBuf
was incorrectly return the error (EOF) before returning the first byte read. It is a valid for an io.Reader to return both n == 1 and err == EOF (see https://pkg.go.dev/io#Reader). ButreadByteBuf
dropped the read byte and instead returned EOF.This checks if we've read a byte and return that first rather than the error. If we're at EOF the next read will return n == 0 and EOF.
Also adds a couple test cases.