9 type T2 struct{ x int }
10 type T3 struct{ X int }
12 type t5 struct{ X int }
14 type T7 struct{ x int }
16 func (T7) MarshalJSON() ([]byte, error) { return nil, nil }
17 func (*T7) UnmarshalJSON([]byte) error { return nil }
19 type T8 struct{ x int }
21 func (T8) MarshalXML() ([]byte, error) { return nil, nil }
22 func (*T8) UnmarshalXML(*xml.Decoder, *xml.StartElement) error { return nil }
26 func (T9) MarshalText() ([]byte, error) { return nil, nil }
27 func (*T9) UnmarshalText([]byte) error { return nil }
30 type T11 struct{ T10 }
34 func (t13) MarshalJSON() ([]byte, error) { return nil, nil }
36 type T14 struct{ t13 }
37 type T15 struct{ *t13 }
38 type T16 struct{ *T3 }
39 type T17 struct{ *T17 }
46 // don't flag structs with no fields
49 json.Marshal(T2{}) // want `struct doesn't have any exported fields, nor custom marshaling`
50 // pointer vs non-pointer makes no difference
51 json.Marshal(&T2{}) // want `struct doesn't have any exported fields, nor custom marshaling`
54 // exported field, pointer makes no difference
56 // embeds struct with exported fields
60 // embeds unexported type, but said type does have exported fields
64 // MarshalXML does not apply to JSON
65 json.Marshal(T8{}) // want `struct doesn't have any exported fields, nor custom marshaling`
68 // embeds exported struct, but it has no fields
69 json.Marshal(T11{}) // want `struct doesn't have any exported fields, nor custom marshaling`
70 // embeds type with MarshalJSON
72 // embeds type with MarshalJSON and type isn't exported
74 // embedded pointer with MarshalJSON
76 // embedded pointer to struct with exported fields
78 // don't recurse forever on recursive data structure
79 json.Marshal(T17{}) // want `struct doesn't have any exported fields, nor custom marshaling`
82 // MarshalJSON does not apply to JSON
83 xml.Marshal(T7{}) // want `struct doesn't have any exported fields, nor custom marshaling`
92 // check that all other variations of methods also work
93 json.Unmarshal(nil, &t2) // want `struct doesn't have any exported fields, nor custom marshaling`
94 json.Unmarshal(nil, &t3)
95 json.Unmarshal(nil, &t9)
96 xml.Unmarshal(nil, &t2) // want `struct doesn't have any exported fields, nor custom marshaling`
97 xml.Unmarshal(nil, &t3)
98 xml.Unmarshal(nil, &t9)
99 (*json.Decoder)(nil).Decode(&t2) // want `struct doesn't have any exported fields, nor custom marshaling`
100 (*json.Decoder)(nil).Decode(&t3)
101 (*json.Decoder)(nil).Decode(&t9)
102 (*json.Encoder)(nil).Encode(t2) // want `struct doesn't have any exported fields, nor custom marshaling`
103 (*json.Encoder)(nil).Encode(t3)
104 (*json.Encoder)(nil).Encode(t9)
105 (*xml.Decoder)(nil).Decode(&t2) // want `struct doesn't have any exported fields, nor custom marshaling`
106 (*xml.Decoder)(nil).Decode(&t3)
107 (*xml.Decoder)(nil).Decode(&t9)
108 (*xml.Encoder)(nil).Encode(t2) // want `struct doesn't have any exported fields, nor custom marshaling`
109 (*xml.Encoder)(nil).Encode(t3)
110 (*xml.Encoder)(nil).Encode(t9)
112 (*json.Decoder)(nil).Decode(&t7)
113 (*json.Decoder)(nil).Decode(&t8) // want `struct doesn't have any exported fields, nor custom marshaling`
114 (*json.Encoder)(nil).Encode(t7)
115 (*json.Encoder)(nil).Encode(t8) // want `struct doesn't have any exported fields, nor custom marshaling`
116 (*xml.Decoder)(nil).Decode(&t7) // want `struct doesn't have any exported fields, nor custom marshaling`
117 (*xml.Decoder)(nil).Decode(&t8)
118 (*xml.Encoder)(nil).Encode(t7) // want `struct doesn't have any exported fields, nor custom marshaling`
119 (*xml.Encoder)(nil).Encode(t8)
123 var _, _ = json.Marshal(T9{})