actgardner / gogen-avro

Generate Go code to serialize and deserialize Avro schemas
MIT License
365 stars 85 forks source link

Question : Would you consider making the templates overridable ? #174

Closed dstendardi closed 2 years ago

dstendardi commented 2 years ago

We would like to hook into the code generation to introduce a custom hook and encrypt specific fields before sending them over the wire.

Would you consider making templates overridable as it is done with velocity in the JVM libraries ?

As this is a question, I did not yet have a proposal on how this could be done, but i would be glad to contribute a MR if you are open to it !

i7tsov commented 2 years ago

You could encrypt fields before serialization and decrypt them after deserialization in your code. Am I missing something?

dstendardi commented 2 years ago

Thanks for the idea @i7tsov . That is an alternative we are considering, however we would like to spare the complexity of reflection after deserialization, and we do think hooking directly into the generated code would help on the matter.

actgardner commented 2 years ago

Hi @dstendardi! I would be open to a way to use pluggable templates, with the caveat that the interface for templates might change in any major release. If you want to put together a PR I could take a look.