-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.1.0
-
Component/s: BSON
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Considering the following example:
Unable to find source-code formatter for language: golang. 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 A struct {
X *B
}
type B struct {
Y string
}
func (B) MarshalBSON() ([]byte, error) {
return bson.Marshal(bson.M{"foo": "bar"})
}
In that case it can marshal A{X: &B} but cannot marshal A{X: nil}
If *B (instead of B) has MarshalBSON implemented it can handle nil pointer. but has no way to represent null in BSON, because MarshalBSON is defaulted to EmbeddedDocument.
I don't know what should return if we implement MarshalBSONValue in *B. "return bsontype.Null, nil, nil" doesn't seem to be correct.