@@ -107,7 +107,7 @@ func (k Kind) IsScalar() bool {
107107// DataDecoder is a decoder for the MMDB data section.
108108// This is exported so mmdbdata package can use it, but still internal.
109109type DataDecoder struct {
110- stringCache * StringCache
110+ stringCache * stringCache
111111 buffer []byte
112112}
113113
@@ -120,17 +120,17 @@ const (
120120func NewDataDecoder (buffer []byte ) DataDecoder {
121121 return DataDecoder {
122122 buffer : buffer ,
123- stringCache : NewStringCache (),
123+ stringCache : newStringCache (),
124124 }
125125}
126126
127- // Buffer returns the underlying buffer for direct access.
128- func (d * DataDecoder ) Buffer () []byte {
127+ // getBuffer returns the underlying buffer for direct access.
128+ func (d * DataDecoder ) getBuffer () []byte {
129129 return d .buffer
130130}
131131
132- // DecodeCtrlData decodes the control byte and data info at the given offset.
133- func (d * DataDecoder ) DecodeCtrlData (offset uint ) (Kind , uint , uint , error ) {
132+ // decodeCtrlData decodes the control byte and data info at the given offset.
133+ func (d * DataDecoder ) decodeCtrlData (offset uint ) (Kind , uint , uint , error ) {
134134 newOffset := offset + 1
135135 if offset >= uint (len (d .buffer )) {
136136 return 0 , 0 , 0 , mmdberrors .NewOffsetError ()
@@ -151,8 +151,8 @@ func (d *DataDecoder) DecodeCtrlData(offset uint) (Kind, uint, uint, error) {
151151 return kindNum , size , newOffset , err
152152}
153153
154- // DecodeBytes decodes a byte slice from the given offset with the given size.
155- func (d * DataDecoder ) DecodeBytes (size , offset uint ) ([]byte , uint , error ) {
154+ // decodeBytes decodes a byte slice from the given offset with the given size.
155+ func (d * DataDecoder ) decodeBytes (size , offset uint ) ([]byte , uint , error ) {
156156 if offset + size > uint (len (d .buffer )) {
157157 return nil , 0 , mmdberrors .NewOffsetError ()
158158 }
@@ -164,7 +164,7 @@ func (d *DataDecoder) DecodeBytes(size, offset uint) ([]byte, uint, error) {
164164}
165165
166166// DecodeFloat64 decodes a 64-bit float from the given offset.
167- func (d * DataDecoder ) DecodeFloat64 (size , offset uint ) (float64 , uint , error ) {
167+ func (d * DataDecoder ) decodeFloat64 (size , offset uint ) (float64 , uint , error ) {
168168 if size != 8 {
169169 return 0 , 0 , mmdberrors .NewInvalidDatabaseError (
170170 "the MaxMind DB file's data section contains bad data (float 64 size of %v)" ,
@@ -181,7 +181,7 @@ func (d *DataDecoder) DecodeFloat64(size, offset uint) (float64, uint, error) {
181181}
182182
183183// DecodeFloat32 decodes a 32-bit float from the given offset.
184- func (d * DataDecoder ) DecodeFloat32 (size , offset uint ) (float32 , uint , error ) {
184+ func (d * DataDecoder ) decodeFloat32 (size , offset uint ) (float32 , uint , error ) {
185185 if size != 4 {
186186 return 0 , 0 , mmdberrors .NewInvalidDatabaseError (
187187 "the MaxMind DB file's data section contains bad data (float32 size of %v)" ,
@@ -198,7 +198,7 @@ func (d *DataDecoder) DecodeFloat32(size, offset uint) (float32, uint, error) {
198198}
199199
200200// DecodeInt32 decodes a 32-bit signed integer from the given offset.
201- func (d * DataDecoder ) DecodeInt32 (size , offset uint ) (int32 , uint , error ) {
201+ func (d * DataDecoder ) decodeInt32 (size , offset uint ) (int32 , uint , error ) {
202202 if size > 4 {
203203 return 0 , 0 , mmdberrors .NewInvalidDatabaseError (
204204 "the MaxMind DB file's data section contains bad data (int32 size of %v)" ,
@@ -218,7 +218,7 @@ func (d *DataDecoder) DecodeInt32(size, offset uint) (int32, uint, error) {
218218}
219219
220220// DecodePointer decodes a pointer from the given offset.
221- func (d * DataDecoder ) DecodePointer (
221+ func (d * DataDecoder ) decodePointer (
222222 size uint ,
223223 offset uint ,
224224) (uint , uint , error ) {
@@ -254,7 +254,7 @@ func (d *DataDecoder) DecodePointer(
254254}
255255
256256// DecodeBool decodes a boolean from the given offset.
257- func (* DataDecoder ) DecodeBool (size , offset uint ) (bool , uint , error ) {
257+ func (* DataDecoder ) decodeBool (size , offset uint ) (bool , uint , error ) {
258258 if size > 1 {
259259 return false , 0 , mmdberrors .NewInvalidDatabaseError (
260260 "the MaxMind DB file's data section contains bad data (bool size of %v)" ,
@@ -266,18 +266,18 @@ func (*DataDecoder) DecodeBool(size, offset uint) (bool, uint, error) {
266266}
267267
268268// DecodeString decodes a string from the given offset.
269- func (d * DataDecoder ) DecodeString (size , offset uint ) (string , uint , error ) {
269+ func (d * DataDecoder ) decodeString (size , offset uint ) (string , uint , error ) {
270270 if offset + size > uint (len (d .buffer )) {
271271 return "" , 0 , mmdberrors .NewOffsetError ()
272272 }
273273
274274 newOffset := offset + size
275- value := d .stringCache .InternAt (offset , size , d .buffer )
275+ value := d .stringCache .internAt (offset , size , d .buffer )
276276 return value , newOffset , nil
277277}
278278
279279// DecodeUint16 decodes a 16-bit unsigned integer from the given offset.
280- func (d * DataDecoder ) DecodeUint16 (size , offset uint ) (uint16 , uint , error ) {
280+ func (d * DataDecoder ) decodeUint16 (size , offset uint ) (uint16 , uint , error ) {
281281 if size > 2 {
282282 return 0 , 0 , mmdberrors .NewInvalidDatabaseError (
283283 "the MaxMind DB file's data section contains bad data (uint16 size of %v)" ,
@@ -299,7 +299,7 @@ func (d *DataDecoder) DecodeUint16(size, offset uint) (uint16, uint, error) {
299299}
300300
301301// DecodeUint32 decodes a 32-bit unsigned integer from the given offset.
302- func (d * DataDecoder ) DecodeUint32 (size , offset uint ) (uint32 , uint , error ) {
302+ func (d * DataDecoder ) decodeUint32 (size , offset uint ) (uint32 , uint , error ) {
303303 if size > 4 {
304304 return 0 , 0 , mmdberrors .NewInvalidDatabaseError (
305305 "the MaxMind DB file's data section contains bad data (uint32 size of %v)" ,
@@ -321,7 +321,7 @@ func (d *DataDecoder) DecodeUint32(size, offset uint) (uint32, uint, error) {
321321}
322322
323323// DecodeUint64 decodes a 64-bit unsigned integer from the given offset.
324- func (d * DataDecoder ) DecodeUint64 (size , offset uint ) (uint64 , uint , error ) {
324+ func (d * DataDecoder ) decodeUint64 (size , offset uint ) (uint64 , uint , error ) {
325325 if size > 8 {
326326 return 0 , 0 , mmdberrors .NewInvalidDatabaseError (
327327 "the MaxMind DB file's data section contains bad data (uint64 size of %v)" ,
@@ -344,7 +344,7 @@ func (d *DataDecoder) DecodeUint64(size, offset uint) (uint64, uint, error) {
344344
345345// DecodeUint128 decodes a 128-bit unsigned integer from the given offset.
346346// Returns the value as high and low 64-bit unsigned integers.
347- func (d * DataDecoder ) DecodeUint128 (size , offset uint ) (hi , lo uint64 , newOffset uint , err error ) {
347+ func (d * DataDecoder ) decodeUint128 (size , offset uint ) (hi , lo uint64 , newOffset uint , err error ) {
348348 if size > 16 {
349349 return 0 , 0 , 0 , mmdberrors .NewInvalidDatabaseError (
350350 "the MaxMind DB file's data section contains bad data (uint128 size of %v)" ,
@@ -375,17 +375,17 @@ func append64(val uint64, b byte) (uint64, byte) {
375375// can take advantage of https://github.com/golang/go/issues/3512 to avoid
376376// copying the bytes when decoding a struct. Previously, we achieved this by
377377// using unsafe.
378- func (d * DataDecoder ) DecodeKey (offset uint ) ([]byte , uint , error ) {
379- kindNum , size , dataOffset , err := d .DecodeCtrlData (offset )
378+ func (d * DataDecoder ) decodeKey (offset uint ) ([]byte , uint , error ) {
379+ kindNum , size , dataOffset , err := d .decodeCtrlData (offset )
380380 if err != nil {
381381 return nil , 0 , err
382382 }
383383 if kindNum == KindPointer {
384- pointer , ptrOffset , err := d .DecodePointer (size , dataOffset )
384+ pointer , ptrOffset , err := d .decodePointer (size , dataOffset )
385385 if err != nil {
386386 return nil , 0 , err
387387 }
388- key , _ , err := d .DecodeKey (pointer )
388+ key , _ , err := d .decodeKey (pointer )
389389 return key , ptrOffset , err
390390 }
391391 if kindNum != KindString {
@@ -404,17 +404,17 @@ func (d *DataDecoder) DecodeKey(offset uint) ([]byte, uint, error) {
404404// NextValueOffset skips ahead to the next value without decoding
405405// the one at the offset passed in. The size bits have different meanings for
406406// different data types.
407- func (d * DataDecoder ) NextValueOffset (offset , numberToSkip uint ) (uint , error ) {
407+ func (d * DataDecoder ) nextValueOffset (offset , numberToSkip uint ) (uint , error ) {
408408 if numberToSkip == 0 {
409409 return offset , nil
410410 }
411- kindNum , size , offset , err := d .DecodeCtrlData (offset )
411+ kindNum , size , offset , err := d .decodeCtrlData (offset )
412412 if err != nil {
413413 return 0 , err
414414 }
415415 switch kindNum {
416416 case KindPointer :
417- _ , offset , err = d .DecodePointer (size , offset )
417+ _ , offset , err = d .decodePointer (size , offset )
418418 if err != nil {
419419 return 0 , err
420420 }
@@ -426,7 +426,7 @@ func (d *DataDecoder) NextValueOffset(offset, numberToSkip uint) (uint, error) {
426426 default :
427427 offset += size
428428 }
429- return d .NextValueOffset (offset , numberToSkip - 1 )
429+ return d .nextValueOffset (offset , numberToSkip - 1 )
430430}
431431
432432func (d * DataDecoder ) sizeFromCtrlByte (
0 commit comments