mennanov / fieldmask-utils

Protobuf Field Mask Go utils
MIT License
229 stars 26 forks source link

Why not support mapToStruct? #35

Closed danwt closed 10 months ago

danwt commented 1 year ago

Why is structToMap supported but not mapToStruct?

Thank you.

mennanov commented 1 year ago

TL; DR: for historical reasons.

The initial goal of this project was copying data from a protobuf struct to some other protobufs struct with a field mask applied. It is also a valid use case to copy from a struct (protobuf) to a map. This is mostly useful for gRPC servers.

Later the copy mechanism was improved to support arbitrary structs (not just protobuf messages), but the set of supported operations stayed the same.

Later on a protobuf specific project was created which supports protobufs only, but in a better way than this project: https://github.com/mennanov/fmutils

Contributions are welcome :)