Closed whitingj closed 5 years ago
Adding an error when the IP is not found to the existing Lookup
method at this point would be a breaking API change as it would break some uses of the library. I am not prepared to do a breaking release at this time. However, I would consider an additional method that does return an error.
Currently, you can use LookupOffset
to determine whether the IP has been found.
I can see why you are hesitant to make a breaking API change. So I would need to do something like this?
ip := net.ParseIP("102.53.124.191")
offset, err := db.LookupOffset(ip)
if ptr != maxminddb.NotFound {
err = db.Decode(offset, &city)
}
I'm somewhat new to the golang community so I'm not sure the best way to approach a potential breaking api change. If the best way to introduce an API change is to have a new method that makes sense to me.
Yes, that should work.
I'd be open to a new method as long as the behavior of the old method stayed the same.
This was resolved by #59 with the new LookupNetwork
method.
When the ip address is not found in the database the library doesn't return an error.
I was able to reproduce this problem using the latest GeoLite2-City.mmdb and the ip address 102.53.124.191. From what I can see at https://www.maxmind.com/en/geoip2-city-database-accuracy MaxMind doesn't promise to resolve all ip addresses so it seems useful to return an error when the ip address can not be found.
Here is code that shows the issue: