Context
In Go Driver v2, we changed the signature of the bson.ValueMarshaler interface (i.e. the MarshalBSONValue function) to return byte instead of bsontype.Type. The intent was to allow 3rd-party libraries to implement the bson.ValueMarshaler interface without depending on the Go Driver module. However, that change created an inconsistency between the bson.MarshalValue function (returns bson.Type) and the bson.ValueMarshaler interface (returns byte). A better change would be to make bson.Type an alias of byte, which would keep the types identical but also not require depending on the Go Driver module to implement the interface.
E.g.
package bson type Type = byte type ValueMarshaler interface { MarshalBSONValue() (typ byte, data []byte, err error) } func MarshalValue(val any) (Type, []byte, error)
Note that we could change the MarshalBSONValue signature to return Type, but it's not clear if that would be confusing to users implementing the interface (i.e. they may think they need to return bson.Type and not realize they can return byte).
Definition of done
What must be done to consider the task complete?
Pitfalls
What should the implementer watch out for? What are the risks?
- is related to
-
GODRIVER-3489 Unify BSON Unmarshaler and ValueUnmarshaler interfaces
-
- Backlog
-
-
GODRIVER-2866 Only use basic Go types in externally-implementable interfaces
-
- Closed
-