-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
Not Needed
-
Summary
when i read a mongo struct from mongodb, then process some filed, marshal to bytes, then store to cache.
when other scenes, get bytes from cache, then unmarshal it , it is not work.
like this:
unmarshal error document is invalid, end byte is at 28, but null byte found at 21
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
the latest version v1.12.0 still has the same bug
How to Reproduce
type P struct
{ Name string `bson:"name,omitempty"` Likes bson.RawValue `bson:"likes,omitempty"` }func TestMismatch(t *testing.T)
{ bytes, err := bson.Marshal(&P\{Name: "lilei"})
if err != nil
var p P
err = bson.Unmarshal(bytes, &p)
if err != nil
}