initial commits

master
Charles Iliya Krempeaux 2021-11-07 16:49:09 -08:00
parent bd279bf5af
commit 1dff92d981
1 changed files with 12 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
const (
serializationprefix = "x"
serializationsuffix = ".id"
)
var (
@ -46,6 +47,9 @@ func serialize(value uint64) string {
wc.Close()
}
{
encoded.WriteString(serializationsuffix)
}
return encoded.String()
}
@ -60,6 +64,14 @@ func unserialize(value string) (uint64, bool) {
value = value[len(serializationprefix):]
}
{
if !strings.HasSuffix(value, serializationsuffix) {
return badvalue, false
}
value = value[:len(value)-len(serializationsuffix)]
}
var p []byte
{
var err error