Skip to content

Commit 7ac8407

Browse files
committed
Update maxminddb to v2.0.0-beta.9 and add OpenBytes method
* Updated maxminddb dependency to v2.0.0-beta.9 * Added OpenBytes method to match API changes in maxminddb library * Deprecated FromBytes method in favor of OpenBytes * Updated documentation to reference OpenBytes instead of FromBytes
1 parent 73544de commit 7ac8407

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 2.0.0-beta.4
2+
3+
* Updated maxminddb dependency to v2.0.0-beta.9.
4+
* Added `OpenBytes` method to match the API changes in maxminddb v2.0.0-beta.9.
5+
* Deprecated `FromBytes` method. Use `OpenBytes` instead. `FromBytes` will be
6+
removed in a future version.
7+
18
# 2.0.0-beta.3 - 2025-07-07
29

310
* Add support for `GeoIP-City-Redacted-US` and `GeoIP-Enterprise-Redacted-US`.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ module github.com/oschwald/geoip2-golang/v2
33
go 1.24
44

55
require (
6-
github.com/oschwald/maxminddb-golang/v2 v2.0.0-beta.8
6+
github.com/oschwald/maxminddb-golang/v2 v2.0.0-beta.9
77
github.com/stretchr/testify v1.10.0
88
)
99

1010
require (
1111
github.com/davecgh/go-spew v1.1.1 // indirect
1212
github.com/pmezard/go-difflib v1.0.0 // indirect
13-
golang.org/x/sys v0.34.0 // indirect
13+
golang.org/x/sys v0.35.0 // indirect
1414
gopkg.in/yaml.v3 v3.0.1 // indirect
1515
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/oschwald/maxminddb-golang/v2 v2.0.0-beta.8 h1:aM1/rO6p+XV+l+seD7UCtFZgsOefDTrFVLvPoZWjXZs=
4-
github.com/oschwald/maxminddb-golang/v2 v2.0.0-beta.8/go.mod h1:Jts8ztuE0PkUwY7VCJyp6B68ujQfr6G9P5Dn3Yx9u6w=
3+
github.com/oschwald/maxminddb-golang/v2 v2.0.0-beta.9 h1:Fc8OfrOEHSDsxEe2MOsNz/7Wq4MNBJczl1/B/+/5k2I=
4+
github.com/oschwald/maxminddb-golang/v2 v2.0.0-beta.9/go.mod h1:EkyB0XWibbE1/+tXyR+ZehlGg66bRtMzxQSPotYH2EA=
55
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
66
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
77
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
88
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
9-
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
10-
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
9+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
10+
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
1111
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1212
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1313
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

reader.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const (
7272
)
7373

7474
// Reader holds the maxminddb.Reader struct. It can be created using the
75-
// Open and FromBytes functions.
75+
// Open and OpenBytes functions.
7676
type Reader struct {
7777
mmdbReader *maxminddb.Reader
7878
databaseType databaseType
@@ -114,19 +114,30 @@ func Open(file string) (*Reader, error) {
114114
return &Reader{reader, dbType}, err
115115
}
116116

117-
// FromBytes takes a byte slice corresponding to a GeoIP2/GeoLite2 database
117+
// OpenBytes takes a byte slice corresponding to a GeoIP2/GeoLite2 database
118118
// file and returns a Reader struct or an error. Note that the byte slice is
119119
// used directly; any modification of it after opening the database will result
120120
// in errors while reading from the database.
121-
func FromBytes(bytes []byte) (*Reader, error) {
122-
reader, err := maxminddb.FromBytes(bytes)
121+
func OpenBytes(bytes []byte) (*Reader, error) {
122+
reader, err := maxminddb.OpenBytes(bytes)
123123
if err != nil {
124124
return nil, err
125125
}
126126
dbType, err := getDBType(reader)
127127
return &Reader{reader, dbType}, err
128128
}
129129

130+
// FromBytes takes a byte slice corresponding to a GeoIP2/GeoLite2 database
131+
// file and returns a Reader struct or an error. Note that the byte slice is
132+
// used directly; any modification of it after opening the database will result
133+
// in errors while reading from the database.
134+
//
135+
// Deprecated: Use OpenBytes instead. FromBytes will be removed in a future
136+
// version.
137+
func FromBytes(bytes []byte) (*Reader, error) {
138+
return OpenBytes(bytes)
139+
}
140+
130141
func getDBType(reader *maxminddb.Reader) (databaseType, error) {
131142
switch reader.Metadata.DatabaseType {
132143
case "GeoIP2-Anonymous-IP":

0 commit comments

Comments
 (0)