-
Notifications
You must be signed in to change notification settings - Fork 301
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
cmd/cue: generate Go code from CUE #6
Comments
Original reply by @tredoe in cuelang/cue#6 (comment) This would be a great feature. Now, I'm using Cue to deal with configuration files and it's the best tool that I've tried. But I've in mind to use it at data validation. Congratulations! |
Original reply by @mpvl in cuelang/cue#6 (comment) Thanks for your kind words. Interesting, I expected the code generation aspect would be more desirable. So note that in the mean time there is https://godoc.org/cuelang.org/go/encoding/gocode, which gets you part of the way. But that assumes the schema are already defined. Generating just the structs should be quite straightforward, though. That would also allow you to retain documentation. It would be implemented using the above-mentioned API. This could then be used to implement a command line feature in the |
I have started playing with cue and I like it, my idea was to first describe the schema of my inputs as a cue file and from there use it to generate to go struct and then validate the input & fill the go structure but I cannot manage to generate go struct from my cue code. My first resource was https://cuelang.org/docs/integrations/go/#generate-go-code which is not that helpful since I have no clue what I like the concept of cue but it generated so much frustration that I think I will keep away from it for now until it matures. |
This is still a desired feature. It is unclear how the general concept would look with multiple language targets. For example, how does one express OOP vs Go type relations, or relations in the context of databases. What about public vs private visibility? The rules are quite varied across the languages and many have concepts that are not representable in CUE without at least attributes. I have been using Some links to what I have been doing:
In the doc you referenced, an instance is a |
Thanks, I will have a look but if this is not currently supported out of the box it should be mentioned explicitly in the documentation, the documentation page I linked is not that. |
Originally opened by @mpvl in cuelang/cue#6
Or really any programming language, but Go is a good first target.
The text was updated successfully, but these errors were encountered: