oschwald / geoip2-golang

Unofficial MaxMind GeoIP2 Reader for Go
ISC License
1.89k stars 195 forks source link

"no such device" error #25

Closed pierrre closed 5 years ago

pierrre commented 7 years ago

Hello,

It's not strictly speaking an error in this library, but you can add a check. If you call geoip2.Open with a path that is a directory instead of a "normal" file, the error "no such device" is returned. I think you should check first the file's type.

Why did it occur in my case ? Because my OS (Linux+Gnome), uncompresses the GeoLite2-Country.mmdb.gz when I double-click it, to a directory named GeoLite2-Country.mmdb which contains a file named data.

oschwald commented 5 years ago

We are just returning the error from os.Open. Following its behavior seems like what most people would expect. I believe it would return an os.PathError in this case.