| 1 |
-- Replace omitempty with omitzero (behavior change) -- |
| 2 |
package omitzero |
| 3 |
|
| 4 |
type Foo struct { |
| 5 |
EmptyStruct struct{} `json:",omitzero"` // want "Omitempty has no effect on nested struct fields" |
| 6 |
} |
| 7 |
|
| 8 |
type Bar struct { |
| 9 |
NonEmptyStruct struct{ a int } `json:",omitzero"` // want "Omitempty has no effect on nested struct fields" |
| 10 |
} |
| 11 |
|
| 12 |
type C struct { |
| 13 |
D string `json:",omitempty"` |
| 14 |
} |
| 15 |
|
| 16 |
type R struct { |
| 17 |
M string `json:",omitempty"` |
| 18 |
} |
| 19 |
|
| 20 |
type A struct { |
| 21 |
C C `json:"test,omitzero"` // want "Omitempty has no effect on nested struct fields" |
| 22 |
R R `json:"test"` |
| 23 |
} |
| 24 |
|
| 25 |
type X struct { |
| 26 |
NonEmptyStruct struct{ a int } `json:",omitzero" yaml:",omitempty"` // want "Omitempty has no effect on nested struct fields" |
| 27 |
} |
| 28 |
|
| 29 |
type Y struct { |
| 30 |
NonEmptyStruct struct{ a int } `yaml:",omitempty" json:",omitzero"` // want "Omitempty has no effect on nested struct fields" |
| 31 |
} |
| 32 |
|
| 33 |
-- Remove redundant omitempty tag -- |
| 34 |
package omitzero |
| 35 |
|
| 36 |
type Foo struct { |
| 37 |
EmptyStruct struct{} // want "Omitempty has no effect on nested struct fields" |
| 38 |
} |
| 39 |
|
| 40 |
type Bar struct { |
| 41 |
NonEmptyStruct struct{ a int } // want "Omitempty has no effect on nested struct fields" |
| 42 |
} |
| 43 |
|
| 44 |
type C struct { |
| 45 |
D string `json:",omitempty"` |
| 46 |
} |
| 47 |
|
| 48 |
type R struct { |
| 49 |
M string `json:",omitempty"` |
| 50 |
} |
| 51 |
|
| 52 |
type A struct { |
| 53 |
C C `json:"test"` // want "Omitempty has no effect on nested struct fields" |
| 54 |
R R `json:"test"` |
| 55 |
} |
| 56 |
|
| 57 |
type X struct { |
| 58 |
NonEmptyStruct struct{ a int } `yaml:",omitempty"` // want "Omitempty has no effect on nested struct fields" |
| 59 |
} |
| 60 |
|
| 61 |
type Y struct { |
| 62 |
NonEmptyStruct struct{ a int } `yaml:",omitempty"` // want "Omitempty has no effect on nested struct fields" |
| 63 |
} |