Oh I expected that since I only called encoder.Encode once, there would only be on repetition of the outermost segment. I was expecting the wireType to be within the inner "(-type id, encoding of a wireType)*" segment. Otherwise shouldn't the spec be
((byteCount, -type id, encoding of a wireType)* (byteCount, type id, encoding of a value))* ? On Tue, Jun 21, 2016 at 8:47 AM Rob Pike <r...@golang.org> wrote: > It's as advertised, 1 count byte (1a=26) followed by 26 bytes, followed by > one count byte (5), followed by 5 bytes. Note the final '*' in that grammar. > -rob > > > On Tue, Jun 21, 2016 at 8:20 AM, Alex Flint <alex.fl...@gmail.com> wrote: > >> The gob docs state that a gob stream consists of >> >> (byteCount (-type id, encoding of a wireType)* (type id, encoding of >> a value))* >> >> I was expecting byteCount to be the number of bytes remaining in the >> entire packet, but that does not seem to be the case. For example when >> encoding a single instance of "struct Number { X int }", the gob stream is >> >> 0000000 1a ff 81 03 01 01 06 4e 75 6d 62 65 72 01 ff 82 >> 0000010 00 01 01 01 01 58 01 04 00 00 00 05 ff 82 01 06 >> 0000020 00 >> >> The entire stream is 33 bytes, so I was expecting the first byte to be >> 0x20, but in fact it is 0x1a. Is this count exclusive of the "(-type id, >> encoding of a wireType)*" segment? >> >> Alex >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.