refactor: add multitype support for keys to marshallMapMsgpack
This commit is contained in:
parent
00157e463c
commit
012c90ddae
|
@ -79,10 +79,21 @@ func marshallMapMsgpack(enc *msgpack.Encoder, m *linkedhashmap.Map) error {
|
||||||
|
|
||||||
iter := m.Iterator()
|
iter := m.Iterator()
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
key := iter.Key().(string)
|
key := iter.Key()
|
||||||
if err := enc.EncodeString(key); err != nil {
|
|
||||||
|
// Determine the type of the key and encode it
|
||||||
|
switch k := key.(type) {
|
||||||
|
case string:
|
||||||
|
if err := enc.EncodeString(k); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
case int:
|
||||||
|
if err := enc.EncodeInt(int64(k)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported key type for encoding")
|
||||||
|
}
|
||||||
|
|
||||||
value := iter.Value()
|
value := iter.Value()
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
|
|
Loading…
Reference in New Issue