News for hackers. Stuff that matters.
Re:Zygomys: Embedded Scripting Language for Go by erik_seaberg on Wednesday June 28, 2023 @10:12PM (#36515513)
Is anyone working on generating compiler-ready boilerplate from macros, rather than running interpretively?
Re:Zygomys: Embedded Scripting Language for Go by thefounder on Wednesday June 28, 2023 @10:40PM (#36515696)
Yes, 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.
Re:Zygomys: Embedded Scripting Language for Go by kubb on Thursday June 29, 2023 @02:38AM (#36517151)
This is one Go's blind spots. It's there, it's solvable most effectively at the language level, it's ignored.
Re:Zygomys: Embedded Scripting Language for Go by liampulles on Thursday June 29, 2023 @04:41AM (#36517929)
I worked on a side project to try and generate mapping code with Go (like mapstruct) but abandoned it: 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.