geoip2-golang icon indicating copy to clipboard operation
geoip2-golang copied to clipboard

*Reader.City returns the zero value if not found

Open celrenheit opened this issue 8 years ago • 1 comments
trafficstars

Hello,

The methods City() and Country should return nil if it finds nothing.

The current behavior is that is returns the zero value: https://github.com/oschwald/geoip2-golang/blob/master/reader.go#L240.

In this case, we have to check if city.GeonameID == 0 to know that it is not found.

Wouldn't it be better to return nil instead ?

celrenheit avatar Aug 23 '17 10:08 celrenheit

This would be a breaking change. I would recommend using maxminddb directly if you want more control over this.

oschwald avatar Aug 23 '17 15:08 oschwald