Skip to content

Commit be6c3db

Browse files
committed
cmd/cue: add get go test case with the new omitzero json tag
This shows the current behavior with the new field tag added in Go 1.24, which is an improvement over omitempty. The following commit will tweak the behavior. For #3869. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I4554cb7d7dec9a59f459768427dce5c2b50a246e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1213250 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
1 parent a6fff27 commit be6c3db

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: cmd/cue/cmd/testdata/script/get_go_types.txtar

+5-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ type Foozer struct {
108108

109109
OptionalOmitEmptyJSON string `json:"optionalOmitEmptyJSON,omitempty"`
110110

111+
OptionalOmitZeroJSON time.Time `json:"optionalOmitZeroJSON,omitzero"`
112+
111113
OptionalOmitEmptyYAML string `yaml:"optionalOmitEmptyYAML,omitempty"`
112114

113115
// +optional
@@ -328,8 +330,9 @@ import (
328330
Embed: {
329331
CustomJSON: #CustomJSON
330332
} @go(,struct{CustomJSON})
331-
optionalOmitEmptyJSON?: string @go(OptionalOmitEmptyJSON)
332-
optionalOmitEmptyYAML?: string @go(OptionalOmitEmptyYAML)
333+
optionalOmitEmptyJSON?: string @go(OptionalOmitEmptyJSON)
334+
optionalOmitZeroJSON: time.Time @go(OptionalOmitZeroJSON)
335+
optionalOmitEmptyYAML?: string @go(OptionalOmitEmptyYAML)
333336

334337
// +optional
335338
optionalComment?: string @go(OptionalComment)

0 commit comments

Comments
 (0)