Last active
August 7, 2021 13:05
-
-
Save pandulaDW/c91ae645464523369f4195d857892f70 to your computer and use it in GitHub Desktop.
reading transaction by transaction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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