Skip to content

Instantly share code, notes, and snippets.

@pandulaDW
Last active August 7, 2021 13:05
Show Gist options
  • Save pandulaDW/c91ae645464523369f4195d857892f70 to your computer and use it in GitHub Desktop.
Save pandulaDW/c91ae645464523369f4195d857892f70 to your computer and use it in GitHub Desktop.
reading transaction by transaction
buf := make([]byte, 4)
if _, err := file.ReadAt(buf, offset); err != nil {
if err == io.EOF {
break
}
return nil, err
}
itemSize := binary.LittleEndian.Uint32(buf)
offset += 4
// reading the actual encoded item
item := make([]byte, itemSize)
if _, err := file.ReadAt(item, offset); err != nil {
if err == io.EOF {
break
}
return nil, err
}
content = append(content, item)
offset += int64(itemSize)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment