Details
-
Bug
-
Resolution: Unresolved
-
Major - P3
-
1.4.4
-
None
-
go 1.15.6
-
Major Change
Description
when set slice point to struct. bson can not decode value in to the origin object
compare to json package. json works well
// code placeholder
|
|
|
type Data struct {
|
Name string `bson:"name"` |
}
|
|
|
type Demo struct {
|
Total []Total `bson:"total"` |
Data []Data `bson:"data"` |
}
|
|
|
var new = Demo{ |
Total: []Total{
|
{
|
Count: 100, |
},
|
},
|
Data: []Data{
|
{
|
"Alice", |
},
|
},
|
}
|
|
|
type receiver struct {
|
Total interface{} |
Data interface{} |
}
|
|
|
func TestUnmarshalBson(t *testing.T) {
|
// a,b not get the value I want |
a := make([]Total, 0) |
b := make([]Data, 0) |
recv := receiver{
|
Total: &a,
|
Data: &b,
|
}
|
}
|
|
Attachments
Issue Links
- is duplicated by
-
GODRIVER-2382 Unmarshaling BSON into a struct with interface fields containing concrete value types doesn't work as expected.
-
- Closed
-