Fix deferInLoop error

Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
z1cheng 2023-09-08 16:20:47 +00:00
parent e5f524268e
commit 9ab342c9e7

View file

@ -179,20 +179,19 @@ func downloadDatabase(dbName string) error {
if !strings.HasSuffix(header.Name, mmdbFile) {
continue
}
return func() error {
outFile, err := os.Create(path.Join(geoIPPath, mmdbFile))
if err != nil {
return err
}
outFile, err := os.Create(path.Join(geoIPPath, mmdbFile))
if err != nil {
return err
}
defer outFile.Close()
//nolint:gocritic // TODO: will fix it on a followup PR
defer outFile.Close()
if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
return err
}
return nil
if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
return err
}
return nil
}()
}
}