@@ -156,48 +156,8 @@ func (r *Reader) Lookup(ip netip.Addr) Result {
156
156
}
157
157
}
158
158
159
- // LookupOffset maps an argument net.IP to a corresponding record offset in the
160
- // database. NotFound is returned if no such record is found, and a record may
161
- // otherwise be extracted by passing the returned offset to Decode. LookupOffset
162
- // is an advanced API, which exists to provide clients with a means to cache
163
- // previously-decoded records.
164
- func (r * Reader ) LookupOffset (ip netip.Addr ) (uintptr , error ) {
165
- if r .buffer == nil {
166
- return 0 , errors .New ("cannot call LookupOffset on a closed database" )
167
- }
168
- pointer , _ , err := r .lookupPointer (ip )
169
- if pointer == 0 || err != nil {
170
- return NotFound , err
171
- }
172
- return r .resolveDataPointer (pointer )
173
- }
174
-
175
159
var zeroIP = netip .MustParseAddr ("::" )
176
160
177
- // Decode the record at |offset| into |result|. The result value pointed to
178
- // must be a data value that corresponds to a record in the database. This may
179
- // include a struct representation of the data, a map capable of holding the
180
- // data or an empty any value.
181
- //
182
- // If result is a pointer to a struct, the struct need not include a field
183
- // for every value that may be in the database. If a field is not present in
184
- // the structure, the decoder will not decode that field, reducing the time
185
- // required to decode the record.
186
- //
187
- // As a special case, a struct field of type uintptr will be used to capture
188
- // the offset of the value. Decode may later be used to extract the stored
189
- // value from the offset. MaxMind DBs are highly normalized: for example in
190
- // the City database, all records of the same country will reference a
191
- // single representative record for that country. This uintptr behavior allows
192
- // clients to leverage this normalization in their own sub-record caching.
193
- func (r * Reader ) Decode (offset uintptr , result any ) error {
194
- if r .buffer == nil {
195
- return errors .New ("cannot call Decode on a closed database" )
196
- }
197
-
198
- return Result {decoder : r .decoder , offset : uint (offset )}.Decode (result )
199
- }
200
-
201
161
func (r * Reader ) lookupPointer (ip netip.Addr ) (uint , int , error ) {
202
162
if r .Metadata .IPVersion == 4 && ip .Is6 () {
203
163
return 0 , 0 , fmt .Errorf (
0 commit comments