cmd/cue: get go
should be tweaked now that we have required fields
#2678
Labels
get go
should be tweaked now that we have required fields
#2678
cue get go
was written back when CUE fields were either regular or optional. CUE v0.6 added required fields per https://github.com/cue-lang/proposal/blob/main/designs/1951-required-fields-v2.md#proposal:cue get go
is about importing Go types as CUE definitions, basically treating them as schemas rather than data. As such, rather than generating CUE fields which are either regular or optional likecue get go
does now, we should generate fields which are either required or optional.The heuristic to decide whether a Go field should become a CUE optional field or not might also need to be tweaked. Right now, most fields are regular unless they have a detail that marks them as optional, such as an
omitempty
field tag option. Because of this, most fields end up being regular. If we simply made all of those fields required, it might lead to some amount of user breakage given how required fields are stricter than regular fields, requiring the field to be declared elsewhere. We might want to tweak the heuristic to also take into account whether a field type is nilable, because in those cases defaulting to a CUE optional field is probably better than a required field.cc @uhthomas @myitcv
The text was updated successfully, but these errors were encountered: