oschwald / maxminddb-golang

MaxMind DB Reader for Go
ISC License
570 stars 99 forks source link

Empty value fails to parse as bool #128

Closed fspinolo closed 5 months ago

fspinolo commented 5 months ago

I am using this library to read a sample mmdb provided by IPInfo at https://github.com/ipinfo/sample-database/blob/main/Privacy%20Detection/privacy_detection_sample.mmdb.

The records contain several boolean fields, and use an empty value to signify "false". This fails with maxminddb: cannot unmarshal into type bool. I would expect it to treat it as a false value (the zero value for a bool in Go).

Can decoding be updated to support this case?

oschwald commented 5 months ago

Unfortunately, I don't see any boolean values in the provided database. I do see strings with values like "true" and "". Similar to encoding/json and other libraries, this library does not support decoding a string to a boolean. Although it is probably too late for them to change it, it would be nice if the database used the correct types when encoding the data.

fspinolo commented 5 months ago

Thanks for confirming the issue! I will take it up with IPInfo.