Allow extracting CUE from and injecting CUE into Go code
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.
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.
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!