Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load from yaml or other generated file types. #16

Open
ZackarySantana opened this issue Feb 18, 2024 · 3 comments
Open

Load from yaml or other generated file types. #16

ZackarySantana opened this issue Feb 18, 2024 · 3 comments

Comments

@ZackarySantana
Copy link

I was able to get a nice flow of loading pkl files nicely on to the generated structs, but I was wondering if there is built-in support for loading other generated file types as well. Brute forcing it with existing tools results in errors since the generated go code often relies in interfaces and then implementations of those interfaces (at least in my use case).

I understand context is lost when it is translated to other file types and in some cases, it would be impossible to determine what struct the data corresponds to- my particular data models don't have any potential conflicts.

No problem if this isn't possible!

Also, one ugly solution I thought of is making some manual structs and relationships so the yaml can grab on to what it needs to. And also I did add yaml struct tags using the generator file.

@obvionaoe
Copy link

I'm also interested in this feature! Would be great if we could load YAML files and still leverage Pkl's evaluation and type checking 🙂

@holzensp
Copy link
Contributor

holzensp commented Apr 3, 2024

This slipped through the cracks. Apologies. I don't fully understand what you're asking. If you have yaml struct tags, you can deserialise (or, in GoSpeak, unmarshall) YAML files into your structs, no? If you want to read YAML in Pkl itself, there's a parser in the "pkl:yaml" module.

@obvionaoe
Copy link

I believe those struct tags only work if you use the go-yaml library which is "sort of" unmaintained. Since Pkl has the ability to parse YAML we were looking for a way to parse YAML files straight into Go leveraging Pkl's validation and type checking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants