serialize from go code to pkl template #230
Replies: 2 comments 4 replies
-
Given a Pkl -> Go generator, "inverting" it to go Go -> Pkl isn't any easier than starting from scratch. You'd need to parse the go structs reliably. That said, if you're not running the Go code generation, because you need extra StructTags, why don't you use |
Beta Was this translation helpful? Give feedback.
-
thanks ill try it :) |
Beta Was this translation helpful? Give feedback.
-
As of my understanding the go integration is perfectly capable of generating go code from a pkl template, however the serialization of go struct into a pkl template isnt a thing
that in my opinion would be really useful, ill provide an example on how and why
im currently writing a k8 operator and the custom CR (a yaml file) is defined by go structs with tags
e.g. of a single struct
and the pkl that would generate similar go code is
this would allow to use the pkl template to generate the yaml for the CR while having the amazing benefits of pkl lang (type checking, custom error sintaxes... )
why not using the pkl to go code generation in this case? because the struct might need as in this case the tags for json serialization.
Beta Was this translation helpful? Give feedback.
All reactions