Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1680

Add typeDecoder interface and dedicated bson.D decoder

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.0
    • Affects Version/s: None
    • Component/s: BSON
    • None

      Introduce an unexported typeDecoder interface to bsoncodec:

      type typeDecoder interface {
          decodeType(DecodeContext, bsonrw.ValueReader) (reflect.Value, error)
      }

      Also add a decodeAdapter type that contains both a typeDecoder and ValueDecoder which can be added to a Registry.

      Modify EmptyInterfaceCodec to implement both typeDecoder and ValueDecoder. When delegating to another codec, it should delegate to typeDecoder if possible and fallback to ValueDecoder if not.

      Add a dedicated bson.D decoder which delegates to the typeDecoder for interface{} if it exists (which it should in the default case) and falls back to ValueDecoder if not (e.g. if the decoder for interface{} has been overriden).

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: