I’m building my custom registry
func NewRegistry() *bsoncodec.Registry {
r := bsoncodec.NewRegistry()
myType := reflect.TypeOf(types.myType{})
r.RegisterTypeEncoder(myType, bsoncodec.ValueEncoderFunc(myTpeEncodeValue))
r.RegisterTypeDecoder(myType, bsoncodec.ValueDecoderFunc(myTypeDecodeValue))
return r
}
myType
is type myType []byte
I have a library on my side to marshal/unmarshal bytes to get a defined struct.
Once inside the encode func I call my Unmarshal I get the concrete struct that look like
type MyStruct struct {
Foo []string
ID string
}
My question is how can I encode this struct?
Should I use call repeadetely inside encode func, the bsonrw.ValueWriter so I can write separately each field?