github.com/oam-dev/kubevela@v1.9.11/references/cuegen/README.md (about)

     1  ## CUE Generator
     2  
     3  Auto generation of CUE schema and docs from Go struct
     4  
     5  ## Type Conversion
     6  
     7  - All comments will be copied to CUE schema
     8  
     9  ### Basic Types
    10  
    11  |      Go Type       | CUE Type  |
    12  |:------------------:|:---------:|
    13  |       `int`        |   `int`   |
    14  |       `int8`       |  `int8`   |
    15  |      `int16`       |  `int16`  |
    16  |      `int32`       |  `int32`  |
    17  |      `int64`       |  `int64`  |
    18  |       `uint`       |  `uint`   |
    19  |      `uint8`       |  `uint8`  |
    20  |      `uint16`      | `uint16`  |
    21  |      `uint32`      | `uint32`  |
    22  |      `uint64`      | `uint64`  |
    23  |     `float32`      | `float32` |
    24  |     `float64`      | `float64` |
    25  |      `string`      | `string`  |
    26  |       `bool`       |  `bool`   |
    27  |       `nil`        |  `null`   |
    28  |       `byte`       |  `uint8`  |
    29  |     `uintptr`      | `uint64`  |
    30  |      `[]byte`      |  `bytes`  |
    31  | `interface{}/any`  |    `_`    |
    32  
    33  ### Map Type
    34  
    35  - CUE only supports `map[string]T` type, which is converted to `[string]: T` in CUE schema
    36  - All `map[string]any/map[string]interface{}` are converted to `{...}` in CUE schema
    37  
    38  ### Struct Type
    39  
    40  - Fields will be expanded recursively in CUE schema
    41  - All unexported fields will be ignored
    42  - Do not support recursive struct type, which will cause infinite loop
    43  
    44  `json` Tag:
    45  
    46  - Fields with `json:"FIELD_NAME"` tag will be renamed to `FIELD_NAME` in CUE schema, otherwise the field name will be
    47    used
    48  - Fields with `json:"-"` tag will be ignored in generation
    49  - Anonymous fields with `json:",inline"` tag will be expanded inlined in CUE schema
    50  - Fields with `json:",omitempty"` tag will be marked as optional in CUE schema
    51  
    52  `cue` Tag:
    53  
    54  - Format: `cue:"key1:value1;key2:value2;boolValue1;boolValue2"`
    55  - Fields with `cue:"enum:VALUE1,VALUE2"` tag will be set with enum values `VALUE1` and `VALUE2` in CUE schema
    56  - Fields with `cue:"default:VALUE"` tag will be set with default value `VALUE` in CUE schema, and `VALUE` must be one of
    57    go basic types, including `int`, `float`, `string`, `bool`
    58  - Separators `';'`, `':'` and `','` can be escaped with `'\'`, e.g. `cue:"default:va\\;lue\\:;enum:e\\;num1,e\\:num2\\,enum3"` will
    59    be parsed as `Default: "va;lue:", Enum: []string{"e;num1", "e:num2,enum3"}}`