initial commits

master
Charles Iliya Krempeaux 2021-11-07 21:05:57 -08:00
parent b42905d454
commit 412a131137
1 changed files with 7 additions and 4 deletions

View File

@ -9,8 +9,8 @@ import (
) )
const ( const (
serializationprefix = "x" serializationprefix = "xi"
serializationsuffix = ".id" serializationsuffix = "m"
) )
var ( var (
@ -27,7 +27,6 @@ func serialize(value uint64) string {
var binstorage bytes.Buffer var binstorage bytes.Buffer
{ {
err := binary.Write(&binstorage, binary.BigEndian, value) err := binary.Write(&binstorage, binary.BigEndian, value)
if nil != err { if nil != err {
return "" return ""
@ -84,12 +83,16 @@ func unserialize(value string) (uint64, bool) {
var result uint64 var result uint64
{ {
var reader io.Reader = bytes.NewReader(p) var reader *bytes.Reader = bytes.NewReader(p)
err := binary.Read(reader, binary.BigEndian, &result) err := binary.Read(reader, binary.BigEndian, &result)
if nil != err { if nil != err {
return badvalue, false return badvalue, false
} }
if expected, actual := 0, reader.Len(); expected != actual {
return badvalue, false
}
} }
return result, true return result, true