Replies: 1 comment
-
Codegen is optional, and not required to use Pkl with Go. We have a (admittedly small) section about it on our website: https://pkl-lang.org/go/current/evaluation.html#without-code-generation PolymorphismIf you are implementing your own codegen and are doing any polymorphism, make sure to read through how pkl-go expects classes to be represented as Go: https://pkl-lang.org/go/current/codegen.html#classes Also: be sure to include a |
Beta Was this translation helpful? Give feedback.
-
I’m considering adding pkl to one of our Go projects. What I don’t like so far is that it seems to require installing the code generation tool first and then generating the code 🙃.
However, looking at the go-examples repo, it seems like the code generation tool isn’t strictly required. It might give you some convenient functions, but that’s about it. Am I right in assuming that? 🤔
Where I’m coming from
Let me explain my reasoning here.
Marshaling and unmarshaling other configuration formats (like JSON) also don’t require a code generation tool. You can simply define a struct, call json.Marshal, and include the struct and JSON as text.
Of course, there are tools like "JSON to Go Struct" (websites), but in general, that approach feels simpler to me. Instead of relying on a code generation tool, you can just work with the data directly.
So, if pkl-go could follow a similar flow to other configuration libraries, wouldn’t it make more sense to:
Provide a website for generating "pkl to Go structs"
Include an example that doesn’t rely on the code generation tool
Maybe I’m missing something, and the code generation tool is super handy. But at first glance, it feels like a bit of unnecessary overhead to me.
Thanks in advance 🎄
Beta Was this translation helpful? Give feedback.
All reactions