@@ -159,10 +159,8 @@ func (d *decoder) unmarshalBool(size uint, offset uint, result reflect.Value) (u
159159 if size > 1 {
160160 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (bool size of %v)" , size )
161161 }
162- value , newOffset , err := d .decodeBool (size , offset )
163- if err != nil {
164- return 0 , err
165- }
162+ value , newOffset := d .decodeBool (size , offset )
163+
166164 switch result .Kind () {
167165 case reflect .Bool :
168166 result .SetBool (value )
@@ -207,10 +205,8 @@ func (d *decoder) indirect(result reflect.Value) reflect.Value {
207205var sliceType = reflect .TypeOf ([]byte {})
208206
209207func (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- }
208+ value , newOffset := d .decodeBytes (size , offset )
209+
214210 switch result .Kind () {
215211 case reflect .Slice :
216212 if result .Type () == sliceType {
@@ -230,10 +226,7 @@ func (d *decoder) unmarshalFloat32(size uint, offset uint, result reflect.Value)
230226 if size != 4 {
231227 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (float32 size of %v)" , size )
232228 }
233- value , newOffset , err := d .decodeFloat32 (size , offset )
234- if err != nil {
235- return 0 , err
236- }
229+ value , newOffset := d .decodeFloat32 (size , offset )
237230
238231 switch result .Kind () {
239232 case reflect .Float32 , reflect .Float64 :
@@ -253,10 +246,8 @@ func (d *decoder) unmarshalFloat64(size uint, offset uint, result reflect.Value)
253246 if size != 8 {
254247 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (float 64 size of %v)" , size )
255248 }
256- value , newOffset , err := d .decodeFloat64 (size , offset )
257- if err != nil {
258- return 0 , err
259- }
249+ value , newOffset := d .decodeFloat64 (size , offset )
250+
260251 switch result .Kind () {
261252 case reflect .Float32 , reflect .Float64 :
262253 if result .OverflowFloat (value ) {
@@ -277,10 +268,7 @@ func (d *decoder) unmarshalInt32(size uint, offset uint, result reflect.Value) (
277268 if size > 4 {
278269 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (int32 size of %v)" , size )
279270 }
280- value , newOffset , err := d .decodeInt (size , offset )
281- if err != nil {
282- return 0 , err
283- }
271+ value , newOffset := d .decodeInt (size , offset )
284272
285273 switch result .Kind () {
286274 case reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 :
@@ -360,11 +348,8 @@ func (d *decoder) unmarshalSlice(
360348}
361349
362350func (d * decoder ) unmarshalString (size uint , offset uint , result reflect.Value ) (uint , error ) {
363- value , newOffset , err := d .decodeString (size , offset )
351+ value , newOffset := d .decodeString (size , offset )
364352
365- if err != nil {
366- return 0 , err
367- }
368353 switch result .Kind () {
369354 case reflect .String :
370355 result .SetString (value )
@@ -384,10 +369,7 @@ func (d *decoder) unmarshalUint(size uint, offset uint, result reflect.Value, ui
384369 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (uint%v size of %v)" , uintType , size )
385370 }
386371
387- value , newOffset , err := d .decodeUint (size , offset )
388- if err != nil {
389- return 0 , err
390- }
372+ value , newOffset := d .decodeUint (size , offset )
391373
392374 switch result .Kind () {
393375 case reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 :
@@ -416,10 +398,7 @@ func (d *decoder) unmarshalUint128(size uint, offset uint, result reflect.Value)
416398 if size > 16 {
417399 return 0 , newInvalidDatabaseError ("the MaxMind DB file's data section contains bad data (uint128 size of %v)" , size )
418400 }
419- value , newOffset , err := d .decodeUint128 (size , offset )
420- if err != nil {
421- return 0 , err
422- }
401+ value , newOffset := d .decodeUint128 (size , offset )
423402
424403 switch result .Kind () {
425404 case reflect .Struct :
@@ -436,36 +415,36 @@ func (d *decoder) unmarshalUint128(size uint, offset uint, result reflect.Value)
436415 return newOffset , newUnmarshalTypeError (value , result .Type ())
437416}
438417
439- func (d * decoder ) decodeBool (size uint , offset uint ) (bool , uint , error ) {
440- return size != 0 , offset , nil
418+ func (d * decoder ) decodeBool (size uint , offset uint ) (bool , uint ) {
419+ return size != 0 , offset
441420}
442421
443- func (d * decoder ) decodeBytes (size uint , offset uint ) ([]byte , uint , error ) {
422+ func (d * decoder ) decodeBytes (size uint , offset uint ) ([]byte , uint ) {
444423 newOffset := offset + size
445424 bytes := make ([]byte , size )
446425 copy (bytes , d .buffer [offset :newOffset ])
447- return bytes , newOffset , nil
426+ return bytes , newOffset
448427}
449428
450- func (d * decoder ) decodeFloat64 (size uint , offset uint ) (float64 , uint , error ) {
429+ func (d * decoder ) decodeFloat64 (size uint , offset uint ) (float64 , uint ) {
451430 newOffset := offset + size
452431 bits := binary .BigEndian .Uint64 (d .buffer [offset :newOffset ])
453- return math .Float64frombits (bits ), newOffset , nil
432+ return math .Float64frombits (bits ), newOffset
454433}
455434
456- func (d * decoder ) decodeFloat32 (size uint , offset uint ) (float32 , uint , error ) {
435+ func (d * decoder ) decodeFloat32 (size uint , offset uint ) (float32 , uint ) {
457436 newOffset := offset + size
458437 bits := binary .BigEndian .Uint32 (d .buffer [offset :newOffset ])
459- return math .Float32frombits (bits ), newOffset , nil
438+ return math .Float32frombits (bits ), newOffset
460439}
461440
462- func (d * decoder ) decodeInt (size uint , offset uint ) (int , uint , error ) {
441+ func (d * decoder ) decodeInt (size uint , offset uint ) (int , uint ) {
463442 newOffset := offset + size
464443 var val int32
465444 for _ , b := range d .buffer [offset :newOffset ] {
466445 val = (val << 8 ) | int32 (b )
467446 }
468- return int (val ), newOffset , nil
447+ return int (val ), newOffset
469448}
470449
471450func (d * decoder ) decodeMap (
@@ -549,9 +528,9 @@ func (d *decoder) decodeSlice(
549528 return offset , nil
550529}
551530
552- func (d * decoder ) decodeString (size uint , offset uint ) (string , uint , error ) {
531+ func (d * decoder ) decodeString (size uint , offset uint ) (string , uint ) {
553532 newOffset := offset + size
554- return string (d .buffer [offset :newOffset ]), newOffset , nil
533+ return string (d .buffer [offset :newOffset ]), newOffset
555534}
556535
557536type fieldsType struct {
@@ -638,23 +617,23 @@ func (d *decoder) decodeStruct(
638617 return offset , nil
639618}
640619
641- func (d * decoder ) decodeUint (size uint , offset uint ) (uint64 , uint , error ) {
620+ func (d * decoder ) decodeUint (size uint , offset uint ) (uint64 , uint ) {
642621 newOffset := offset + size
643622 bytes := d .buffer [offset :newOffset ]
644623
645624 var val uint64
646625 for _ , b := range bytes {
647626 val = (val << 8 ) | uint64 (b )
648627 }
649- return val , newOffset , nil
628+ return val , newOffset
650629}
651630
652- func (d * decoder ) decodeUint128 (size uint , offset uint ) (* big.Int , uint , error ) {
631+ func (d * decoder ) decodeUint128 (size uint , offset uint ) (* big.Int , uint ) {
653632 newOffset := offset + size
654633 val := new (big.Int )
655634 val .SetBytes (d .buffer [offset :newOffset ])
656635
657- return val , newOffset , nil
636+ return val , newOffset
658637}
659638
660639func uintFromBytes (prefix uint , uintBytes []byte ) uint {
0 commit comments