mirror of
https://github.com/MarekWojt/gertdns.git
synced 2025-12-15 21:09:51 +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)
|
f, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
color.Warnf("Could not load file for domain %s: %s\n", currentDomain.Root, err)
|
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)
|
log.Printf("Reading file: %s", filePath)
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
|
|
||||||
@@ -110,8 +113,6 @@ func loadFile(ty string, currentDomain *domain) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
color.Infof("Read file: %s\n", filePath)
|
color.Infof("Read file: %s\n", filePath)
|
||||||
}
|
|
||||||
f.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init(dataPath string) {
|
func Init(dataPath string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user