🐛 WriteValue can handle slices and maps
This commit is contained in:
parent
820a2de269
commit
59634f6c3f
2 changed files with 14 additions and 0 deletions
|
|
@ -14,6 +14,18 @@ func WriteValue(buff *bytes.Buffer, val any) (n int, err error) {
|
|||
err = fmt.Errorf("Unsupported type %T", v)
|
||||
case nil:
|
||||
return
|
||||
case []any:
|
||||
var o []byte
|
||||
o, err = json.Marshal(v)
|
||||
if err == nil {
|
||||
return buff.Write(o)
|
||||
}
|
||||
case map[string]any:
|
||||
var o []byte
|
||||
o, err = json.Marshal(v)
|
||||
if err == nil {
|
||||
return buff.Write(o)
|
||||
}
|
||||
case string:
|
||||
return buff.WriteString(v)
|
||||
case int:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue