-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalizing save/restore for SQLiteStateMachine
- Loading branch information
Showing
4 changed files
with
182 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package lib | ||
|
||
import ( | ||
"encoding/binary" | ||
"io" | ||
) | ||
|
||
func writeUint32(writer io.Writer, val uint32) error { | ||
buf := make([]byte, 4) | ||
binary.BigEndian.PutUint32(buf, val) | ||
_, err := writer.Write(buf) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func readUint32(reader io.Reader) (uint32, error) { | ||
buff := make([]byte, 4, 4) | ||
_, err := io.LimitReader(reader, 4).Read(buff) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
val := binary.BigEndian.Uint32(buff) | ||
return val, nil | ||
} |