Reading to the end of a protobuf.Buffer

208 views
Skip to first unread message

Tonny Staunsbrink

unread,
Jul 28, 2016, 2:18:58 PM7/28/16
to Protocol Buffers
Is there a graceful way to detect having reached the end of a protobuf.Buffer (Golang)? 
I always end up with unexpected EOF

Adam Cozzette

unread,
Jul 29, 2016, 6:31:44 PM7/29/16
to Tonny Staunsbrink, Protocol Buffers, Ross Light
+Ross who is the expert on protocol buffers for Go

I'm not familiar with the Go implementation so I may be misunderstanding your question, but it sounds to me like you are trying to parse a protocol buffer without knowing its size. Protocol buffers are not self-delimiting, so it's not possible to parse them without knowing the number of bytes to expect, and that may be the problem you're running into. The usual solution to this is to prefix each serialized proto with its size in bytes.

On Wed, Jul 27, 2016 at 12:30 PM, Tonny Staunsbrink <12b...@gmail.com> wrote:
Is there a graceful way to detect having reached the end of a protobuf.Buffer (Golang)? 
I always end up with unexpected EOF

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Ross Light

unread,
Jul 29, 2016, 6:34:18 PM7/29/16
to Adam Cozzette, Tonny Staunsbrink, Protocol Buffers
+1 to Adam's assessment. That sounds like what you're running into, Tonny.

-Ross
Reply all
Reply to author
Forward
0 new messages