-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
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:
Unable to find source-code formatter for language: example.go. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
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.