It occurred to me a few weeks ago why programming languages don't just try add metaprogramming capabilities with comments, without modifying the original compiler. So I went ahead and experimented how would it look like in golang.
So far so good! It's basically go templates that take in any package level go symbol and write code into a meta.go file.
You can do the same with the go/ast package, but metago makes it very easy to add your own custom transformations. No build tags, just write .metago templates, annotate structs, and run metago.
So far I've managed to make stringer, enums, mocks and even an efficient json serde template with metago. As an experiment, there's also a typesafe active record like orm in the repo. So you can do a lot with it!
It occurred to me a few weeks ago why programming languages don't just try add metaprogramming capabilities with comments, without modifying the original compiler. So I went ahead and experimented how would it look like in golang.
So far so good! It's basically go templates that take in any package level go symbol and write code into a meta.go file.
You can do the same with the go/ast package, but metago makes it very easy to add your own custom transformations. No build tags, just write .metago templates, annotate structs, and run metago.
So far I've managed to make stringer, enums, mocks and even an efficient json serde template with metago. As an experiment, there's also a typesafe active record like orm in the repo. So you can do a lot with it!