Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
None
Description
This can be considered a follow-up of GODRIVER-842, that the custom interfaces inside arrays or structs cannot be marshaled.
Example is shown as follows:
type I interface {}
|
|
|
type A struct {
|
X string
|
}
|
|
|
type B struct {
|
Y I
|
}
|
|
|
func (*A) Hello() {}
|
|
|
func main() {
|
a := A{X: "meow"}
|
b := B{Y: &a}
|
_, err := bson.Marshal(b)
|
fmt.Println(err)
|
}
|
It returns "no encoder found for main.I" in current state. However, bson.Marshal can actaully work with interface{} inside struct, as well as custom interfaces if it is not inside a struct, so I would expect interface{} inside struct should work.