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) { if !strings.HasSuffix(header.Name, mmdbFile) {
continue continue
} }
return func() error {
outFile, err := os.Create(path.Join(geoIPPath, mmdbFile)) outFile, err := os.Create(path.Join(geoIPPath, mmdbFile))
if err != nil { if err != nil {
return err return err
} }
//nolint:gocritic // TODO: will fix it on a followup PR
defer outFile.Close() defer outFile.Close()
if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil { if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
return err return err
} }
return nil return nil
}()
} }
} }