go - Append to golang gob in a file on disk -


i'm trying save gob-encoded data in file on disk simple datastore. however, when open next time gob encoder ignores whatever data in file, , starts on sending definitions of sent formats before sending data. seeing gob.encoder takes io.writer, rather io.readwriter, makes sense. encoder has no idea what's in file, because cannot read it.

this is, however, quite inefficient. it's unnecessarily hard parse, since have reset decoder each time encoder restarted when writing file, since gob type id's might've changed.

how can continue write end of file containing gob data? have create new file, moving data on gob encoder knows types sent, or there way me tell encoder types should know already, or other way? need work across software restarts.

it not possible reconstruct encoder state other encoder had when writing stream of gob values. if cannot use original encoder when appending values, have couple of options:

  • move data on suggest.
  • use framing mechanism store multiple gob streams single file. example, can prefix each gob stream length of stream.

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -