Error from close is not propagated outside
graywolf-at-work opened this issue · comments
graywolf-at-work commented
The error from os.Close
is stored to err
, which is the one created here https://github.com/oschwald/maxminddb-golang/blob/master/reader_other.go#L16 .
That means that the assigment here
maxminddb-golang/reader_other.go
Line 22 in 302864b
Either this https://github.com/oschwald/maxminddb-golang/blob/master/reader_other.go#L15 should be
func Open(file string) (r *Reader, err error) {
but since that would mask actual error with one from os.Close, I think better option would be to just replace
defer func() {
if rerr := mapFile.Close(); rerr != nil {
err = rerr
}
}()
with
defer func() {
mapFile.Close()
}()
As written right now the code probably does not do what was intended.
Gregory Oschwald commented
Thanks! This was fixed in df020c7.