@@ -27,8 +27,10 @@ const (
2727 _Uint64
2828 _Uint128
2929 _Slice
30- _Container
31- _Marker
30+ // We don't use the next two. They are placeholders. See the spec
31+ // for more details.
32+ _Container // nolint: deadcode, varcheck
33+ _Marker // nolint: deadcode, varcheck
3234 _Bool
3335 _Float32
3436)
@@ -159,10 +161,8 @@ func (d *decoder) unmarshalBool(size uint, offset uint, result reflect.Value) (u
159161 if size > 1 {
160162 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (bool size of %v)" , size )
161163 }
162- value , newOffset , err := d .decodeBool (size , offset )
163- if err != nil {
164- return 0 , err
165- }
164+ value , newOffset := d .decodeBool (size , offset )
165+
166166 switch result .Kind () {
167167 case reflect .Bool :
168168 result .SetBool (value )
@@ -207,10 +207,8 @@ func (d *decoder) indirect(result reflect.Value) reflect.Value {
207207var sliceType = reflect .TypeOf ([]byte {})
208208
209209func (d * decoder ) unmarshalBytes (size uint , offset uint , result reflect.Value ) (uint , error ) {
210- value , newOffset , err := d .decodeBytes (size , offset )
211- if err != nil {
212- return 0 , err
213- }
210+ value , newOffset := d .decodeBytes (size , offset )
211+
214212 switch result .Kind () {
215213 case reflect .Slice :
216214 if result .Type () == sliceType {
@@ -230,10 +228,7 @@ func (d *decoder) unmarshalFloat32(size uint, offset uint, result reflect.Value)
230228 if size != 4 {
231229 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (float32 size of %v)" , size )
232230 }
233- value , newOffset , err := d .decodeFloat32 (size , offset )
234- if err != nil {
235- return 0 , err
236- }
231+ value , newOffset := d .decodeFloat32 (size , offset )
237232
238233 switch result .Kind () {
239234 case reflect .Float32 , reflect .Float64 :
@@ -253,10 +248,8 @@ func (d *decoder) unmarshalFloat64(size uint, offset uint, result reflect.Value)
253248 if size != 8 {
254249 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (float 64 size of %v)" , size )
255250 }
256- value , newOffset , err := d .decodeFloat64 (size , offset )
257- if err != nil {
258- return 0 , err
259- }
251+ value , newOffset := d .decodeFloat64 (size , offset )
252+
260253 switch result .Kind () {
261254 case reflect .Float32 , reflect .Float64 :
262255 if result .OverflowFloat (value ) {
@@ -277,10 +270,7 @@ func (d *decoder) unmarshalInt32(size uint, offset uint, result reflect.Value) (
277270 if size > 4 {
278271 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (int32 size of %v)" , size )
279272 }
280- value , newOffset , err := d .decodeInt (size , offset )
281- if err != nil {
282- return 0 , err
283- }
273+ value , newOffset := d .decodeInt (size , offset )
284274
285275 switch result .Kind () {
286276 case reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 :
@@ -360,11 +350,8 @@ func (d *decoder) unmarshalSlice(
360350}
361351
362352func (d * decoder ) unmarshalString (size uint , offset uint , result reflect.Value ) (uint , error ) {
363- value , newOffset , err := d .decodeString (size , offset )
353+ value , newOffset := d .decodeString (size , offset )
364354
365- if err != nil {
366- return 0 , err
367- }
368355 switch result .Kind () {
369356 case reflect .String :
370357 result .SetString (value )
@@ -384,10 +371,7 @@ func (d *decoder) unmarshalUint(size uint, offset uint, result reflect.Value, ui
384371 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (uint%v size of %v)" , uintType , size )
385372 }
386373
387- value , newOffset , err := d .decodeUint (size , offset )
388- if err != nil {
389- return 0 , err
390- }
374+ value , newOffset := d .decodeUint (size , offset )
391375
392376 switch result .Kind () {
393377 case reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 :
@@ -416,10 +400,7 @@ func (d *decoder) unmarshalUint128(size uint, offset uint, result reflect.Value)
416400 if size > 16 {
417401 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (uint128 size of %v)" , size )
418402 }
419- value , newOffset , err := d .decodeUint128 (size , offset )
420- if err != nil {
421- return 0 , err
422- }
403+ value , newOffset := d .decodeUint128 (size , offset )
423404
424405 switch result .Kind () {
425406 case reflect .Struct :
@@ -436,36 +417,36 @@ func (d *decoder) unmarshalUint128(size uint, offset uint, result reflect.Value)
436417 return newOffset , newUnmarshalTypeError (value , result .Type ())
437418}
438419
439- func (d * decoder ) decodeBool (size uint , offset uint ) (bool , uint , error ) {
440- return size != 0 , offset , nil
420+ func (d * decoder ) decodeBool (size uint , offset uint ) (bool , uint ) {
421+ return size != 0 , offset
441422}
442423
443- func (d * decoder ) decodeBytes (size uint , offset uint ) ([]byte , uint , error ) {
424+ func (d * decoder ) decodeBytes (size uint , offset uint ) ([]byte , uint ) {
444425 newOffset := offset + size
445426 bytes := make ([]byte , size )
446427 copy (bytes , d .buffer [offset :newOffset ])
447- return bytes , newOffset , nil
428+ return bytes , newOffset
448429}
449430
450- func (d * decoder ) decodeFloat64 (size uint , offset uint ) (float64 , uint , error ) {
431+ func (d * decoder ) decodeFloat64 (size uint , offset uint ) (float64 , uint ) {
451432 newOffset := offset + size
452433 bits := binary .BigEndian .Uint64 (d .buffer [offset :newOffset ])
453- return math .Float64frombits (bits ), newOffset , nil
434+ return math .Float64frombits (bits ), newOffset
454435}
455436
456- func (d * decoder ) decodeFloat32 (size uint , offset uint ) (float32 , uint , error ) {
437+ func (d * decoder ) decodeFloat32 (size uint , offset uint ) (float32 , uint ) {
457438 newOffset := offset + size
458439 bits := binary .BigEndian .Uint32 (d .buffer [offset :newOffset ])
459- return math .Float32frombits (bits ), newOffset , nil
440+ return math .Float32frombits (bits ), newOffset
460441}
461442
462- func (d * decoder ) decodeInt (size uint , offset uint ) (int , uint , error ) {
443+ func (d * decoder ) decodeInt (size uint , offset uint ) (int , uint ) {
463444 newOffset := offset + size
464445 var val int32
465446 for _ , b := range d .buffer [offset :newOffset ] {
466447 val = (val << 8 ) | int32 (b )
467448 }
468- return int (val ), newOffset , nil
449+ return int (val ), newOffset
469450}
470451
471452func (d * decoder ) decodeMap (
@@ -511,7 +492,7 @@ func (d *decoder) decodePointer(
511492 if pointerSize == 4 {
512493 prefix = 0
513494 } else {
514- prefix = uint ( size & 0x7 )
495+ prefix = size & 0x7
515496 }
516497 unpacked := uintFromBytes (prefix , pointerBytes )
517498
@@ -549,9 +530,9 @@ func (d *decoder) decodeSlice(
549530 return offset , nil
550531}
551532
552- func (d * decoder ) decodeString (size uint , offset uint ) (string , uint , error ) {
533+ func (d * decoder ) decodeString (size uint , offset uint ) (string , uint ) {
553534 newOffset := offset + size
554- return string (d .buffer [offset :newOffset ]), newOffset , nil
535+ return string (d .buffer [offset :newOffset ]), newOffset
555536}
556537
557538type fieldsType struct {
@@ -638,23 +619,23 @@ func (d *decoder) decodeStruct(
638619 return offset , nil
639620}
640621
641- func (d * decoder ) decodeUint (size uint , offset uint ) (uint64 , uint , error ) {
622+ func (d * decoder ) decodeUint (size uint , offset uint ) (uint64 , uint ) {
642623 newOffset := offset + size
643624 bytes := d .buffer [offset :newOffset ]
644625
645626 var val uint64
646627 for _ , b := range bytes {
647628 val = (val << 8 ) | uint64 (b )
648629 }
649- return val , newOffset , nil
630+ return val , newOffset
650631}
651632
652- func (d * decoder ) decodeUint128 (size uint , offset uint ) (* big.Int , uint , error ) {
633+ func (d * decoder ) decodeUint128 (size uint , offset uint ) (* big.Int , uint ) {
653634 newOffset := offset + size
654635 val := new (big.Int )
655636 val .SetBytes (d .buffer [offset :newOffset ])
656637
657- return val , newOffset , nil
638+ return val , newOffset
658639}
659640
660641func uintFromBytes (prefix uint , uintBytes []byte ) uint {
0 commit comments