pull in latest go-kv, go-cache (#1530)

Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
kim
2023-02-19 09:36:38 +00:00
committed by GitHub
parent a0068e8915
commit 51c156cca1
16 changed files with 451 additions and 224 deletions

View File

@@ -5,6 +5,43 @@ import (
"unsafe"
)
type (
// serializing interfacing types.
stringer interface{ String() string }
binarymarshaler interface{ MarshalBinary() ([]byte, error) }
textmarshaler interface{ MarshalText() ([]byte, error) }
jsonmarshaler interface{ MarshalJSON() ([]byte, error) }
)
func append_uint16(b []byte, u uint16) []byte {
return append(b, // LE
byte(u),
byte(u>>8),
)
}
func append_uint32(b []byte, u uint32) []byte {
return append(b, // LE
byte(u),
byte(u>>8),
byte(u>>16),
byte(u>>24),
)
}
func append_uint64(b []byte, u uint64) []byte {
return append(b, // LE
byte(u),
byte(u>>8),
byte(u>>16),
byte(u>>24),
byte(u>>32),
byte(u>>40),
byte(u>>48),
byte(u>>56),
)
}
func deref_ptr_mangler(mangle Mangler, count int) rMangler {
return func(buf []byte, v reflect.Value) []byte {
for i := 0; i < count; i++ {
@@ -43,6 +80,16 @@ func deref_ptr_rmangler(mangle rMangler, count int) rMangler {
}
}
func array_to_slice_mangler(mangle Mangler) rMangler {
return func(buf []byte, v reflect.Value) []byte {
// Get slice of whole array
v = v.Slice(0, v.Len())
// Mangle as known slice type
return mangle(buf, v.Interface())
}
}
func iter_array_mangler(mangle Mangler) rMangler {
return func(buf []byte, v reflect.Value) []byte {
n := v.Len()
@@ -78,7 +125,7 @@ func iter_map_rmangler(kMangle, vMangle rMangler) rMangler {
buf = kMangle(buf, r.Key())
buf = append(buf, ':')
buf = vMangle(buf, r.Value())
buf = append(buf, '.')
buf = append(buf, ',')
}
if v.Len() > 0 {
buf = buf[:len(buf)-1]