Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/oschwald/maxminddb-golang
/ functions
Functions
386 in github.com/oschwald/maxminddb-golang
⨍
Functions
386
◇
Types & classes
99
↓ 66 callers
Method
Decode
Decode unmarshals the data from the data section into the value pointed to by v. If v is nil or not a pointer, an error is returned. If the data in th
result.go:31
↓ 57 callers
Function
New
New creates a [ReflectionDecoder].
internal/decoder/reflection.go:30
↓ 53 callers
Function
Open
Open takes a string path to a MaxMind DB file and any options. It returns a Reader structure or an error. The database file is opened using a memory m
reader.go:224
↓ 51 callers
Function
NewInvalidDatabaseError
NewInvalidDatabaseError creates an [InvalidDatabaseError] using the provided format and format arguments.
internal/mmdberrors/errors.go:24
↓ 49 callers
Method
Close
Close returns the resources used by the database to the system.
reader.go:302
↓ 48 callers
Method
Decode
Decode decodes the data value at offset and stores it in the value pointed at by v.
internal/decoder/reflection.go:68
↓ 48 callers
Method
Lookup
Lookup retrieves the database record for ip and returns a Result, which can be used to decode the data.
reader.go:381
↓ 46 callers
Function
testFile
(file string)
reader_test.go:1405
↓ 40 callers
Method
Error
()
internal/mmdberrors/context.go:18
↓ 38 callers
Method
Err
Err provides a way to check whether there was an error during the lookup without calling Result.Decode. If there was an error, it will also be returne
result.go:108
↓ 33 callers
Function
NewDataDecoder
NewDataDecoder creates a [DataDecoder].
internal/decoder/data_decoder.go:121
↓ 29 callers
Method
wrapError
wrapError wraps an error with context information when an error occurs. Zero allocation on happy path - only allocates when error != nil.
internal/decoder/error_context.go:7
↓ 27 callers
Function
NewDecoder
NewDecoder creates a new Decoder with the given DataDecoder, offset, and options.
internal/decoder/decoder.go:31
↓ 25 callers
Method
ReadString
ReadString reads the value pointed by the decoder as a string. Returns an error if the database is malformed or if the pointed value is not a string.
internal/decoder/decoder.go:63
↓ 25 callers
Method
String
String returns a human-readable name for the Kind.
internal/decoder/data_decoder.go:51
↓ 22 callers
Method
Error
()
mmap_unix.go:14
↓ 22 callers
Method
Prefix
Prefix returns the netip.Prefix representing the network associated with the data record in the database.
result.go:131
↓ 19 callers
Method
decodeCtrlData
decodeCtrlData decodes the control byte and data info at the given offset. Encoding follows the MaxMind DB spec: the control byte's high 3 bits encode
internal/decoder/data_decoder.go:139
↓ 18 callers
Method
DecodePath
DecodePath unmarshals a value from data section into v, following the specified path. The v parameter should be a pointer to the value where the deco
result.go:92
↓ 17 callers
Function
NewOffsetError
NewOffsetError creates an [InvalidDatabaseError] indicating that an offset pointed beyond the end of the database.
internal/mmdberrors/errors.go:18
↓ 14 callers
Method
Found
Found will return true if the IP was found in the search tree. It will return false if the IP was not found or if there was an error.
result.go:114
↓ 14 callers
Method
Networks
Networks returns an iterator that can be used to traverse the networks in the database. Please note that a MaxMind DB may map IPv4 networks into seve
traverse.go:70
↓ 13 callers
Method
ReadMap
ReadMap returns an iterator to read the map along with the map size. The size can be used to pre-allocate a map with the correct capacity for better p
internal/decoder/decoder.go:221
↓ 13 callers
Function
newDecoderFromHex
Helper function to create a Decoder for a given hex string.
internal/decoder/decoder_test.go:15
↓ 13 callers
Method
nextValueOffset
NextValueOffset skips ahead to the next value without decoding the one at the offset passed in. The size bits have different meanings for different da
internal/decoder/data_decoder.go:541
↓ 12 callers
Method
decodeCtrlDataAndFollow
(expectedKind Kind)
internal/decoder/decoder.go:413
↓ 12 callers
Function
validateDecoding
(t *testing.T, tests map[string]any)
internal/decoder/reflection_test.go:550
↓ 11 callers
Method
setNextOffset
(offset uint)
internal/decoder/decoder.go:402
↓ 10 callers
Method
decodeKey
DecodeKey decodes a map key into []byte slice. We use a []byte so that we can take advantage of https://github.com/golang/go/issues/3512 to avoid copy
internal/decoder/data_decoder.go:467
↓ 10 callers
Method
internAt
internAt returns a string for the data at the given offset and size. Hot offsets are interned and the same backing string is returned on subsequent hi
internal/decoder/string_cache.go:36
↓ 9 callers
Function
NewUnmarshalTypeError
NewUnmarshalTypeError creates an [UnmarshalTypeError] when the value cannot be assigned to a value of rType.
internal/mmdberrors/errors.go:50
↓ 9 callers
Function
OpenBytes
OpenBytes takes a byte slice corresponding to a MaxMind DB file and any options. It returns a Reader structure or an error.
reader.go:313
↓ 9 callers
Method
reset
(offset uint)
internal/decoder/decoder.go:396
↓ 8 callers
Function
WrapWithContext
WrapWithContext wraps an error with offset and optional path context. This function is designed to have zero allocation on the happy path - it only al
internal/mmdberrors/context.go:41
↓ 8 callers
Method
decodePointer
DecodePointer decodes a pointer from the given offset.
internal/decoder/data_decoder.go:247
↓ 8 callers
Method
decodeValue
( offset uint, result addressableValue, depth int, )
internal/decoder/reflection.go:258
↓ 8 callers
Function
randomIPv4Address
(r *rand.Rand, ip []byte)
reader_test.go:1395
↓ 7 callers
Method
LookupOffset
LookupOffset returns the Result for the specified offset. Note that netip.Prefix returned by Networks will be invalid when using LookupOffset.
reader.go:412
↓ 7 callers
Method
NetworksWithin
NetworksWithin returns an iterator that can be used to traverse the networks in the database which are contained in a given prefix. Please note that
traverse.go:90
↓ 7 callers
Function
newStringCache
()
internal/decoder/string_cache.go:28
↓ 7 callers
Function
testError
( field string, expected any, actual any, )
verifier.go:153
↓ 6 callers
Method
Build
Build constructs the full path string.
internal/mmdberrors/context.go:89
↓ 6 callers
Method
PrependMap
PrependMap adds a map key to the beginning of the path (for retroactive building).
internal/mmdberrors/context.go:79
↓ 5 callers
Function
NewPathBuilder
NewPathBuilder creates a new path builder.
internal/mmdberrors/context.go:67
↓ 5 callers
Method
Offset
Offset returns the offset of the record in the database. This can be passed to (*Reader).LookupOffset. It can also be used as a unique identifier for
result.go:125
↓ 5 callers
Method
PeekKind
PeekKind returns the kind of the current value without consuming it. This allows for look-ahead parsing similar to jsontext.Decoder.PeekKind().
internal/decoder/decoder.go:316
↓ 5 callers
Method
ReadUint32
ReadUint32 reads the value pointed by the decoder as a uint32. Returns an error if the database is malformed or if the pointed value is not a uint32.
internal/decoder/decoder.go:163
↓ 5 callers
Function
SkipEmptyValues
SkipEmptyValues is an option for Networks and NetworksWithin that makes them skip networks whose data is an empty map or empty array. This is useful f
traverse.go:54
↓ 5 callers
Method
decode
(offset uint, result reflect.Value, depth int)
internal/decoder/reflection.go:242
↓ 5 callers
Function
searchTreeSizeBytes
(nodeCount, recordSize uint)
reader.go:375
↓ 4 callers
Function
NewUnmarshalTypeStrError
NewUnmarshalTypeStrError creates an [UnmarshalTypeError] when the string value cannot be assigned to a value of rType.
internal/mmdberrors/errors.go:41
↓ 4 callers
Method
ReadSlice
ReadSlice returns an iterator over the values of the slice along with the slice size. The size can be used to pre-allocate a slice with the correct ca
internal/decoder/decoder.go:266
↓ 4 callers
Method
Verify
Verify performs comprehensive validation of the MaxMind DB file. This method validates: - Metadata section: format versions, required fields, and val
verifier.go:30
↓ 4 callers
Function
cachedFields
(result reflect.Value)
internal/decoder/reflection.go:1260
↓ 4 callers
Function
checkNestedDepth
(depth int)
internal/decoder/reflection.go:1060
↓ 4 callers
Method
decodeString
DecodeString decodes a string from the given offset.
internal/decoder/data_decoder.go:295
↓ 4 callers
Method
decodeStructWithFields
( size uint, offset uint, result addressableValue, depth int, fields *fieldsType, )
internal/decoder/reflection.go:864
↓ 4 callers
Method
decodeUint16
DecodeUint16 decodes a 16-bit unsigned integer from the given offset.
internal/decoder/data_decoder.go:306
↓ 4 callers
Method
decodeUint32
DecodeUint32 decodes a 32-bit unsigned integer from the given offset.
internal/decoder/data_decoder.go:328
↓ 4 callers
Method
decodeUint64
DecodeUint64 decodes a 64-bit unsigned integer from the given offset.
internal/decoder/data_decoder.go:350
↓ 4 callers
Method
decodeValueSkipUnmarshaler
decodeValueSkipUnmarshaler is the struct-field fast path: when the destination type was precomputed to not implement Unmarshaler, we skip the reflecti
internal/decoder/reflection.go:269
↓ 4 callers
Function
makeStructFields
makeStructFields implements json/v2 style field precedence rules.
internal/decoder/reflection.go:1293
↓ 3 callers
Function
IncludeNetworksWithoutData
IncludeNetworksWithoutData is an option for Networks and NetworksWithin that makes them include networks without any data in the iteration.
traverse.go:44
↓ 3 callers
Method
IsContainer
IsContainer returns true if the Kind represents a container type (Map or Slice).
internal/decoder/data_decoder.go:91
↓ 3 callers
Method
IsEmptyValueAt
IsEmptyValueAt checks if the value at the given offset is an empty map or array. Returns true if the value is a map or array with size 0.
internal/decoder/reflection.go:38
↓ 3 callers
Method
IsScalar
IsScalar returns true if the Kind represents a scalar value type.
internal/decoder/data_decoder.go:96
↓ 3 callers
Method
ReadUint64
ReadUint64 reads the value pointed by the decoder as a uint64. Returns an error if the database is malformed or if the pointed value is not a uint64.
internal/decoder/decoder.go:181
↓ 3 callers
Method
SkipValue
SkipValue skips over the current value without decoding it. This is useful in custom decoders when encountering unknown fields. The decoder will be po
internal/decoder/decoder.go:304
↓ 3 callers
Method
decodeBool
DecodeBool decodes a boolean from the given offset.
internal/decoder/data_decoder.go:283
↓ 3 callers
Method
decodeFloat64
DecodeFloat64 decodes a 64-bit float from the given offset.
internal/decoder/data_decoder.go:193
↓ 3 callers
Function
getAllTestMMDBFiles
getAllTestMMDBFiles returns smaller MMDB files from the test-data directory. Large files are excluded to keep fuzzing fast and prevent timeouts.
fuzz_test.go:365
↓ 3 callers
Method
getBuffer
getBuffer returns the underlying buffer for direct access.
internal/decoder/data_decoder.go:129
↓ 3 callers
Function
hasBufferRange
(bufferLen, offset, size uint)
reader.go:785
↓ 3 callers
Function
isInIPv4Subtree
isInIPv4Subtree returns true if the IP is in the database's IPv4 subtree.
traverse.go:264
↓ 3 callers
Function
mappedIP
(ip netip.Addr)
traverse.go:256
↓ 3 callers
Function
munmap
(_ []byte)
mmap_stub.go:23
↓ 3 callers
Method
traverseTree
(ip netip.Addr, node uint, stopBit int)
reader.go:528
↓ 3 callers
Method
traverseTree24
(ip netip.Addr, node uint, stopBit int)
reader.go:544
↓ 3 callers
Method
traverseTree28
(ip netip.Addr, node uint, stopBit int)
reader.go:615
↓ 3 callers
Method
traverseTree32
(ip netip.Addr, node uint, stopBit int)
reader.go:712
↓ 3 callers
Method
unmarshalUint
( size, offset uint, result addressableValue, uintType uint, )
internal/decoder/reflection.go:658
↓ 3 callers
Function
v6ToV4
Converts an IPv4 address embedded in IPv6 to IPv4.
traverse.go:275
↓ 2 callers
Method
BuildTime
BuildTime returns the database build time as a time.Time. This is a convenience method that converts the BuildEpoch field from Unix epoch seconds to a
reader.go:203
↓ 2 callers
Method
ParseAndExtend
ParseAndExtend parses an existing path and extends this builder with those segments. This is used for retroactive path building during error unwinding
internal/mmdberrors/context.go:98
↓ 2 callers
Method
PrependSlice
PrependSlice adds a slice index to the beginning of the path (for retroactive building).
internal/mmdberrors/context.go:84
↓ 2 callers
Method
ReadBool
ReadBool reads the value pointed by the decoder as a bool. Returns an error if the database is malformed or if the pointed value is not a bool.
internal/decoder/decoder.go:46
↓ 2 callers
Method
ReadBytes
ReadBytes reads the value pointed by the decoder as bytes. Returns an error if the database is malformed or if the pointed value is not bytes.
internal/decoder/decoder.go:80
↓ 2 callers
Method
ReadFloat64
ReadFloat64 reads the value pointed by the decoder as a float64. Returns an error if the database is malformed or if the pointed value is not a doubl
internal/decoder/decoder.go:109
↓ 2 callers
Method
ReadUint128
ReadUint128 reads the value pointed by the decoder as a uint128. Returns an error if the database is malformed or if the pointed value is not a uint1
internal/decoder/decoder.go:199
↓ 2 callers
Method
ReadUint16
ReadUint16 reads the value pointed by the decoder as a uint16. Returns an error if the database is malformed or if the pointed value is not a uint16.
internal/decoder/decoder.go:145
↓ 2 callers
Method
UnmarshalMaxMindDB
(d *Decoder)
mmdbdata/interface.go:6
↓ 2 callers
Function
append64
(val uint64, b byte)
internal/decoder/data_decoder.go:396
↓ 2 callers
Function
cachedFieldsForTypeWithStack
( resultType reflect.Type, stack map[reflect.Type]bool, )
internal/decoder/reflection.go:1268
↓ 2 callers
Function
checkIpv4
(t *testing.T, reader *Reader)
reader_test.go:1041
↓ 2 callers
Function
checkIpv6
(t *testing.T, reader *Reader)
reader_test.go:1082
↓ 2 callers
Function
checkMetadata
(t *testing.T, reader *Reader, ipVersion, recordSize uint)
reader_test.go:1016
↓ 2 callers
Function
cleanupAllocatedPointers
( allocatedCount int, allocated1, allocated2 reflect.Value, allocatedMore []reflect.Value, )
internal/decoder/reflection.go:1112
↓ 2 callers
Method
decodeFloat32
DecodeFloat32 decodes a 32-bit float from the given offset.
internal/decoder/data_decoder.go:210
↓ 2 callers
Method
decodeInt32
DecodeInt32 decodes a 32-bit signed integer from the given offset.
internal/decoder/data_decoder.go:227
↓ 2 callers
Method
decodeMap
( size uint, offset uint, result addressableValue, depth int, )
internal/decoder/reflection.go:777
next →
1–100 of 386, ranked by callers