Closed fredr closed 7 months ago
An error is not returned if there are no results. An error is returned if the database is corrupt or there is a result that cannot be unmarshaled into the value provided. I assume you are referring to the discussion around the latter.
If you want to check whether a record exists, I would suggest using LookupNetwork
, which returns a boolean indicating this.
I was referring to the documentation saying If result is nil or not a pointer, an error is returned.
. Maybe that could be phrased differently so that it is more clear?
"result" throughout that documentation is referring to the result
param. Renaming it to v
or something may make the documentation a bit clearer.
In the comments of the Lookup function, it states that an error will be returned when there is no results (in my interpretation). But as far as I can tell that is not true.
The comment I'm referring to: https://github.com/oschwald/maxminddb-golang/blob/main/reader.go#L129
This is where both the pointer in 0 and err is nil: https://github.com/oschwald/maxminddb-golang/blob/main/reader.go#L269
Causing this to return nil, even though it might look like an error is returned: https://github.com/oschwald/maxminddb-golang/blob/main/reader.go#L138-L140
Did I misunderstand the comment? or shoud an error be returned when no results where found?