Per the documentation:
omitempty: If the omitempty struct tag is specified on a field, the field will not be marshalled if it is set to
the zero value. By default, a struct field is only considered empty if the field’s type implements the Zeroer
interface and the IsZero method returns true. Struct fields of types that do not implement Zeroer are always
marshalled as embedded documents. This tag should be used for all slice and map values.
Since golang primitives don’t implement Zeroer, passing usual zero values (such as bool(false), int(0), string("")) still get encoded into the bson objects.
Is the appropriate path to create a new Registry, registering bsoncodec.DefaultValueEncoders/bsoncodec.DefaultValueDecoders, and then registering my custom Type Encoder for each type I want to implement IsTypeZeroer
?