mirror of
https://github.com/MarekWojt/gertdns.git
synced 2025-12-15 12:59:53 +01:00
defer closing file when loading data
This commit is contained in:
@@ -89,7 +89,10 @@ func loadFile(ty string, currentDomain *domain) {
|
||||
f, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
color.Warnf("Could not load file for domain %s: %s\n", currentDomain.Root, err)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
log.Printf("Reading file: %s", filePath)
|
||||
scanner := bufio.NewScanner(f)
|
||||
|
||||
@@ -110,8 +113,6 @@ func loadFile(ty string, currentDomain *domain) {
|
||||
}
|
||||
}
|
||||
color.Infof("Read file: %s\n", filePath)
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
|
||||
func Init(dataPath string) {
|
||||
|
||||
Reference in New Issue
Block a user