@@ -42,7 +42,9 @@ const (
42
42
43
43
func (d * decoder ) decode (offset uint , result reflect.Value , depth int ) (uint , error ) {
44
44
if depth > maximumDataStructureDepth {
45
- return 0 , newInvalidDatabaseError ("exceeded maximum data structure depth; database is likely corrupt" )
45
+ return 0 , newInvalidDatabaseError (
46
+ "exceeded maximum data structure depth; database is likely corrupt" ,
47
+ )
46
48
}
47
49
typeNum , size , newOffset , err := d .decodeCtrlData (offset )
48
50
if err != nil {
@@ -56,9 +58,16 @@ func (d *decoder) decode(offset uint, result reflect.Value, depth int) (uint, er
56
58
return d .decodeFromType (typeNum , size , newOffset , result , depth + 1 )
57
59
}
58
60
59
- func (d * decoder ) decodeToDeserializer (offset uint , dser deserializer , depth int , getNext bool ) (uint , error ) {
61
+ func (d * decoder ) decodeToDeserializer (
62
+ offset uint ,
63
+ dser deserializer ,
64
+ depth int ,
65
+ getNext bool ,
66
+ ) (uint , error ) {
60
67
if depth > maximumDataStructureDepth {
61
- return 0 , newInvalidDatabaseError ("exceeded maximum data structure depth; database is likely corrupt" )
68
+ return 0 , newInvalidDatabaseError (
69
+ "exceeded maximum data structure depth; database is likely corrupt" ,
70
+ )
62
71
}
63
72
skip , err := dser .ShouldSkip (uintptr (offset ))
64
73
if err != nil {
@@ -100,7 +109,11 @@ func (d *decoder) decodeCtrlData(offset uint) (dataType, uint, uint, error) {
100
109
return typeNum , size , newOffset , err
101
110
}
102
111
103
- func (d * decoder ) sizeFromCtrlByte (ctrlByte byte , offset uint , typeNum dataType ) (uint , uint , error ) {
112
+ func (d * decoder ) sizeFromCtrlByte (
113
+ ctrlByte byte ,
114
+ offset uint ,
115
+ typeNum dataType ,
116
+ ) (uint , uint , error ) {
104
117
size := uint (ctrlByte & 0x1f )
105
118
if typeNum == _Extended {
106
119
return size , offset , nil
@@ -244,7 +257,10 @@ func (d *decoder) decodeFromTypeToDeserializer(
244
257
245
258
func (d * decoder ) unmarshalBool (size , offset uint , result reflect.Value ) (uint , error ) {
246
259
if size > 1 {
247
- return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (bool size of %v)" , size )
260
+ return 0 , newInvalidDatabaseError (
261
+ "the MaxMind DB file's data section contains bad data (bool size of %v)" ,
262
+ size ,
263
+ )
248
264
}
249
265
value , newOffset := d .decodeBool (size , offset )
250
266
@@ -312,7 +328,10 @@ func (d *decoder) unmarshalBytes(size, offset uint, result reflect.Value) (uint,
312
328
313
329
func (d * decoder ) unmarshalFloat32 (size , offset uint , result reflect.Value ) (uint , error ) {
314
330
if size != 4 {
315
- return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (float32 size of %v)" , size )
331
+ return 0 , newInvalidDatabaseError (
332
+ "the MaxMind DB file's data section contains bad data (float32 size of %v)" ,
333
+ size ,
334
+ )
316
335
}
317
336
value , newOffset := d .decodeFloat32 (size , offset )
318
337
@@ -331,7 +350,10 @@ func (d *decoder) unmarshalFloat32(size, offset uint, result reflect.Value) (uin
331
350
332
351
func (d * decoder ) unmarshalFloat64 (size , offset uint , result reflect.Value ) (uint , error ) {
333
352
if size != 8 {
334
- return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (float 64 size of %v)" , size )
353
+ return 0 , newInvalidDatabaseError (
354
+ "the MaxMind DB file's data section contains bad data (float 64 size of %v)" ,
355
+ size ,
356
+ )
335
357
}
336
358
value , newOffset := d .decodeFloat64 (size , offset )
337
359
@@ -353,7 +375,10 @@ func (d *decoder) unmarshalFloat64(size, offset uint, result reflect.Value) (uin
353
375
354
376
func (d * decoder ) unmarshalInt32 (size , offset uint , result reflect.Value ) (uint , error ) {
355
377
if size > 4 {
356
- return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (int32 size of %v)" , size )
378
+ return 0 , newInvalidDatabaseError (
379
+ "the MaxMind DB file's data section contains bad data (int32 size of %v)" ,
380
+ size ,
381
+ )
357
382
}
358
383
value , newOffset := d .decodeInt (size , offset )
359
384
@@ -364,7 +389,12 @@ func (d *decoder) unmarshalInt32(size, offset uint, result reflect.Value) (uint,
364
389
result .SetInt (n )
365
390
return newOffset , nil
366
391
}
367
- case reflect .Uint , reflect .Uint8 , reflect .Uint16 , reflect .Uint32 , reflect .Uint64 , reflect .Uintptr :
392
+ case reflect .Uint ,
393
+ reflect .Uint8 ,
394
+ reflect .Uint16 ,
395
+ reflect .Uint32 ,
396
+ reflect .Uint64 ,
397
+ reflect .Uintptr :
368
398
n := uint64 (value )
369
399
if ! result .OverflowUint (n ) {
370
400
result .SetUint (n )
@@ -404,7 +434,11 @@ func (d *decoder) unmarshalMap(
404
434
}
405
435
}
406
436
407
- func (d * decoder ) unmarshalPointer (size , offset uint , result reflect.Value , depth int ) (uint , error ) {
437
+ func (d * decoder ) unmarshalPointer (
438
+ size , offset uint ,
439
+ result reflect.Value ,
440
+ depth int ,
441
+ ) (uint , error ) {
408
442
pointer , newOffset , err := d .decodePointer (size , offset )
409
443
if err != nil {
410
444
return 0 , err
@@ -450,9 +484,17 @@ func (d *decoder) unmarshalString(size, offset uint, result reflect.Value) (uint
450
484
return newOffset , newUnmarshalTypeError (value , result .Type ())
451
485
}
452
486
453
- func (d * decoder ) unmarshalUint (size , offset uint , result reflect.Value , uintType uint ) (uint , error ) {
487
+ func (d * decoder ) unmarshalUint (
488
+ size , offset uint ,
489
+ result reflect.Value ,
490
+ uintType uint ,
491
+ ) (uint , error ) {
454
492
if size > uintType / 8 {
455
- return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (uint%v size of %v)" , uintType , size )
493
+ return 0 , newInvalidDatabaseError (
494
+ "the MaxMind DB file's data section contains bad data (uint%v size of %v)" ,
495
+ uintType ,
496
+ size ,
497
+ )
456
498
}
457
499
458
500
value , newOffset := d .decodeUint (size , offset )
@@ -464,7 +506,12 @@ func (d *decoder) unmarshalUint(size, offset uint, result reflect.Value, uintTyp
464
506
result .SetInt (n )
465
507
return newOffset , nil
466
508
}
467
- case reflect .Uint , reflect .Uint8 , reflect .Uint16 , reflect .Uint32 , reflect .Uint64 , reflect .Uintptr :
509
+ case reflect .Uint ,
510
+ reflect .Uint8 ,
511
+ reflect .Uint16 ,
512
+ reflect .Uint32 ,
513
+ reflect .Uint64 ,
514
+ reflect .Uintptr :
468
515
if ! result .OverflowUint (value ) {
469
516
result .SetUint (value )
470
517
return newOffset , nil
@@ -482,7 +529,10 @@ var bigIntType = reflect.TypeOf(big.Int{})
482
529
483
530
func (d * decoder ) unmarshalUint128 (size , offset uint , result reflect.Value ) (uint , error ) {
484
531
if size > 16 {
485
- return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (uint128 size of %v)" , size )
532
+ return 0 , newInvalidDatabaseError (
533
+ "the MaxMind DB file's data section contains bad data (uint128 size of %v)" ,
534
+ size ,
535
+ )
486
536
}
487
537
value , newOffset := d .decodeUint128 (size , offset )
488
538
0 commit comments