summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-mangler/helpers.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-02-19 09:36:38 +0000
committerLibravatar GitHub <noreply@github.com>2023-02-19 10:36:38 +0100
commit51c156cca1b88e2f5bcf649c86a7e7736ffbb652 (patch)
tree6187d78b93a051256226e68d66e72ba4c0cfa409 /vendor/codeberg.org/gruf/go-mangler/helpers.go
parent[bugfix] In Postgres, drop shortcodedomain constraint before creating new emo... (diff)
downloadgotosocial-51c156cca1b88e2f5bcf649c86a7e7736ffbb652.tar.xz
pull in latest go-kv, go-cache (#1530)
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-mangler/helpers.go')
-rw-r--r--vendor/codeberg.org/gruf/go-mangler/helpers.go49
1 files changed, 48 insertions, 1 deletions
diff --git a/vendor/codeberg.org/gruf/go-mangler/helpers.go b/vendor/codeberg.org/gruf/go-mangler/helpers.go
index 0ca4498af..6658fbef4 100644
--- a/vendor/codeberg.org/gruf/go-mangler/helpers.go
+++ b/vendor/codeberg.org/gruf/go-mangler/helpers.go
@@ -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]