cue icon indicating copy to clipboard operation
cue copied to clipboard

Allow extracting CUE from and injecting CUE into Go code

Open cueckoo opened this issue 4 years ago • 2 comments

Originally opened by @mpvl in https://github.com/cuelang/cue/issues/24

This is a tracking issue related to extracting CUE from Go code. The functionality in this issue focusses on use cases where Go is used as the source of truth. Issue #6 focusses on generating Go assuming that CUE is used as the source of truth.

injection: Allow annotation of Go types with additional CUE constraints and provide a simple API to validate and complete Go values.

extraction: The primary extraction method looks at struct definitions in Go code, determines how these would be interpreted by the encoding/json package, and then generates CUE definitions for such structs. In addition, we can extract CUE annotations used in Go code for validation to augment such definitions.

cueckoo avatar Jul 03 '21 10:07 cueckoo

Original reply by @Meai1 in https://github.com/cuelang/cue/issues/24#issuecomment-508647908

I didnt want to make a new issue for this but this from the docs doesnt currently create any files:

$ cue get go k8s.io/api/core/v1
$ cue get go k8s.io/api/extensions/v1beta1
$ cue get go k8s.io/api/apps/v1beta1

All it does is create folders with no files in them.

EDIT: Ok it works after doing a go get first, but there was no error message that the underlying go package was missing.

cueckoo avatar Jul 03 '21 10:07 cueckoo

Original reply by @errordeveloper in https://github.com/cuelang/cue/issues/24#issuecomment-628833751

@Meai1 I stumbled upon that too, sounds like a bug in the docs!

cueckoo avatar Jul 03 '21 10:07 cueckoo