reading float32 from float64 without error
This commit is contained in:
parent
9324aeae5f
commit
219428c7f6
|
@ -255,6 +255,21 @@ func decodeBool(dec *msgpack.Decoder, v *bool) error {
|
|||
}
|
||||
|
||||
func decodeFloat32(dec *msgpack.Decoder, v *float32) error {
|
||||
code, err := dec.PeekCode()
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
if code == msgpcode.Double {
|
||||
var tmp float64
|
||||
if err := decodeFloat64(dec, &tmp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*v = float32(tmp)
|
||||
return nil
|
||||
}
|
||||
|
||||
tmp, err := dec.DecodeFloat32()
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
|
|
Loading…
Reference in New Issue