Skip to content

Commit

Permalink
Fix deferInLoop error
Browse files Browse the repository at this point in the history
Signed-off-by: z1cheng <[email protected]>
  • Loading branch information
z1cheng committed Sep 8, 2023
1 parent e5f5242 commit 9ab342c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions internal/nginx/maxmind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

//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
}
defer outFile.Close()

return nil
if _, err := io.CopyN(outFile, tarReader, header.Size); err != nil {
return err
}
return nil
}()
}
}

Expand Down

0 comments on commit 9ab342c

Please sign in to comment.