@@ -18,9 +18,9 @@ func (mt marshalText) MarshalText() ([]byte, error) {
18
18
19
19
var _ encoding.TextMarshaler = marshalText (struct {}{})
20
20
21
- // JSONMarshalSaveTypesWithNoSafe contains a multitude of test cases to marshal different combinations of types to JSON,
22
- // that are save , that is, they will never return an error, if these types are marshaled to JSON.
23
- func JSONMarshalSaveTypesWithNoSafe () {
21
+ // JSONMarshalSafeTypesWithNoSafe contains a multitude of test cases to marshal different combinations of types to JSON,
22
+ // that are safe , that is, they will never return an error, if these types are marshaled to JSON.
23
+ func JSONMarshalSafeTypesWithNoSafe () {
24
24
var err error
25
25
26
26
_ , _ = json .Marshal (nil ) // ERROR "Error return value of `encoding/json.Marshal` is not checked"
@@ -253,7 +253,7 @@ func JSONMarshalSaveTypesWithNoSafe() {
253
253
254
254
type (
255
255
structKey struct { id int }
256
- ExportedUnsafeAndInvalidStruct struct { // unsafe unexported but ommited
256
+ ExportedUnsafeAndInvalidStruct struct { // unsafe unexported but omitted
257
257
F64 float64
258
258
F64Ptr * float64
259
259
F64Slice []float64
@@ -282,7 +282,7 @@ type (
282
282
}
283
283
)
284
284
285
- // JSONMarshalSaveStructWithUnexportedFields contains a struct with unexported, unsafe fields.
285
+ // JSONMarshalSafeStructWithUnexportedFieldsWithNoSafe contains a struct with unexported, unsafe fields.
286
286
func JSONMarshalSaveStructWithUnexportedFieldsWithNoSafe () {
287
287
var err error
288
288
@@ -347,49 +347,49 @@ func JSONMarshalSaveStructWithUnexportedFieldsWithNoSafe() {
347
347
_ = err
348
348
}
349
349
350
- // JSONMarshalSaveStructWithOmittedFields contains a struct with omitted, unsafe fields.
350
+ // JSONMarshalSafeStructWithOmittedFieldsWithNoSafe contains a struct with omitted, unsafe fields.
351
351
func JSONMarshalSaveStructWithOmittedFieldsWithNoSafe () {
352
352
var err error
353
353
354
354
var ommitInStruct struct {
355
355
Bool bool // safe exported
356
356
357
- F64 float64 `json:"-"` // unsafe exported but ommited
358
- F64Ptr * float64 `json:"-"` // unsafe exported but ommited
359
- F64Slice []float64 `json:"-"` // unsafe exported but ommited
360
- F64Array [10 ]float64 `json:"-"` // unsafe exported but ommited
361
- MapStrF64 map [string ]float64 `json:"-"` // unsafe exported but ommited
362
- MapEIStr map [interface {}]string `json:"-"` // unsafe exported but ommited
363
- Number json.Number `json:"-"` // unsafe exported but ommited
364
- NumberPtr * json.Number `json:"-"` // unsafe exported but ommited
365
- NumberSlice []json.Number `json:"-"` // unsafe exported but ommited
366
- MapNumberStr map [json.Number ]string `json:"-"` // unsafe exported but ommited
367
- Ei interface {} `json:"-"` // unsafe exported but ommited
368
- Stringer fmt.Stringer `json:"-"` // unsafe exported but ommited
369
- Mt marshalText `json:"-"` // unsafe exported but ommited
370
- MapMarshalTextString map [marshalText ]string `json:"-"` // unsafe exported but ommited
371
- ExportedStruct ExportedUnsafeAndInvalidStruct `json:"-"` // unsafe exported but ommited
372
- ExportedStructPtr * ExportedUnsafeAndInvalidStruct `json:"-"` // unsafe exported but ommited
373
-
374
- C128 complex128 `json:"-"` // invalid exported but ommited
375
- C128Slice []complex128 `json:"-"` // invalid exported but ommited
376
- C128Array [10 ]complex128 `json:"-"` // invalid exported but ommited
377
- MapBoolStr map [bool ]string `json:"-"` // invalid exported but ommited
378
- MapF64Str map [float64 ]string `json:"-"` // invalid exported but ommited
379
- F func () `json:"-"` // invalid exported but ommited
380
- Ch chan struct {} `json:"-"` // invalid exported but ommited
381
- UnsafePtr unsafe.Pointer `json:"-"` // invalid exported but ommited
382
- MapStructStr map [structKey ]string `json:"-"` // invalid exported but ommited
357
+ F64 float64 `json:"-"` // unsafe exported but omitted
358
+ F64Ptr * float64 `json:"-"` // unsafe exported but omitted
359
+ F64Slice []float64 `json:"-"` // unsafe exported but omitted
360
+ F64Array [10 ]float64 `json:"-"` // unsafe exported but omitted
361
+ MapStrF64 map [string ]float64 `json:"-"` // unsafe exported but omitted
362
+ MapEIStr map [interface {}]string `json:"-"` // unsafe exported but omitted
363
+ Number json.Number `json:"-"` // unsafe exported but omitted
364
+ NumberPtr * json.Number `json:"-"` // unsafe exported but omitted
365
+ NumberSlice []json.Number `json:"-"` // unsafe exported but omitted
366
+ MapNumberStr map [json.Number ]string `json:"-"` // unsafe exported but omitted
367
+ Ei interface {} `json:"-"` // unsafe exported but omitted
368
+ Stringer fmt.Stringer `json:"-"` // unsafe exported but omitted
369
+ Mt marshalText `json:"-"` // unsafe exported but omitted
370
+ MapMarshalTextString map [marshalText ]string `json:"-"` // unsafe exported but omitted
371
+ ExportedStruct ExportedUnsafeAndInvalidStruct `json:"-"` // unsafe exported but omitted
372
+ ExportedStructPtr * ExportedUnsafeAndInvalidStruct `json:"-"` // unsafe exported but omitted
373
+
374
+ C128 complex128 `json:"-"` // invalid exported but omitted
375
+ C128Slice []complex128 `json:"-"` // invalid exported but omitted
376
+ C128Array [10 ]complex128 `json:"-"` // invalid exported but omitted
377
+ MapBoolStr map [bool ]string `json:"-"` // invalid exported but omitted
378
+ MapF64Str map [float64 ]string `json:"-"` // invalid exported but omitted
379
+ F func () `json:"-"` // invalid exported but omitted
380
+ Ch chan struct {} `json:"-"` // invalid exported but omitted
381
+ UnsafePtr unsafe.Pointer `json:"-"` // invalid exported but omitted
382
+ MapStructStr map [structKey ]string `json:"-"` // invalid exported but omitted
383
383
}
384
384
_ = ommitInStruct .MapStructStr [structKey {1 }]
385
385
_ , _ = json .Marshal (ommitInStruct ) // ERROR "Error return value of `encoding/json.Marshal` is not checked"
386
386
_ , err = json .Marshal (ommitInStruct ) // struct containing unsafe but omitted, exported fields is safe, but omit-safe is set
387
387
_ = err
388
388
}
389
389
390
- // JSONMarshalUnsaveTypes contains a multitude of test cases to marshal different combinations of types to JSON,
390
+ // JSONMarshalUnsafeTypes contains a multitude of test cases to marshal different combinations of types to JSON,
391
391
// that can potentially lead to json.Marshal returning an error.
392
- func JSONMarshalUnsaveTypes () {
392
+ func JSONMarshalUnsafeTypes () {
393
393
var err error
394
394
395
395
var f32 float32
0 commit comments