The LookupEncoder and LookupDecoder methods on bsoncodec.Registry prevent looking up a default codec for maps with non-string keys. While the default map encoder and decoder does not support non-string keys, users who wish to do so should be able to register their own default encoder and decoder for maps with non-string keys. Users can already register a default map encoder or decoder that handles non-string keys.
Remove the check from LookupEncoder and LookupDecoder that prevents returning the default map encoder or decoder if the map's key is not a string.
(original description below)
Why bson package cannot resolve map[int]int, while encoding/json and mgo can.
https://github.com/globalsign/mgo/pull/140
I wrote a MapEncoder for myself, then call RegisterDefaultEncoder(). It is stuck in
(r *Registry) LookupEncoder(t reflect.Type) (ValueEncoder, error) {
...
if t != nil && t.Kind() == reflect.Map && t.Key().Kind() != reflect.String
{ ... }I cannot implement a mapEncoder/Decoder without modifying this driver.
Please support numeric map keys.