3 ms·
Is anyone working on generating compiler-ready boilerplate from macros, rather than running interpretively?
by erik_seaberg 3y ago
Is anyone working on generating compiler-ready boilerplate from macros, rather than running interpretively?
- thefounder 3y agoYes, I did that extensively and ended up using reflection only. The code generation/generated is just hard to maintain and the tools that generate the code (and read the code) are hard to maintain as well. Currently I'm using code "reading" only to extract documentation so no more code generation.
- kubb 3y agoThis is one Go's blind spots. It's there, it's solvable most effectively at the language level, it's ignored.
- liampulles 3y agoI worked on a side project to try and generate mapping code with Go (like mapstruct) but abandoned it: https://github.com/liampulles/juryrig https://github.com/liampulles/juryrig I do wish there was a nice library to aid in parsing Go, there may be one I'm not aware of - I used the standard AST library but it is very verbose. Actually generating the code is very easy and go format helps a lot. Custom kubernetes operators in Go use code generation via comments extensively, perhaps worth looking at.