Set TimeNotBuiltin msgpack option directly without using BasicHandle

Prevents a situation where when attempting to decode a string into a nil
interface, the decoded value would be the encoded slice of bytes instead
of the string we need.
This commit is contained in:
ionutboangiu
2023-07-12 08:53:42 -04:00
committed by Dan Christian Bogos
parent df3ae97e57
commit 628df25caa
2 changed files with 30 additions and 3 deletions

View File

@@ -265,9 +265,7 @@ func NewCodecMsgpackMarshaler() *CodecMsgpackMarshaler {
mh := new(codec.MsgpackHandle)
mh.MapType = reflect.TypeOf(map[string]any(nil))
mh.RawToString = true
mh.BasicHandle = codec.BasicHandle{
TimeNotBuiltin: true,
}
mh.TimeNotBuiltin = true
return &CodecMsgpackMarshaler{mh}
}