Log error when failing to close the config file

This commit is contained in:
Maximilian 2022-12-14 15:23:48 -06:00
parent 8c93b3746b
commit 007830ab33

View File

@ -35,7 +35,12 @@ func LoadConfig() Configuration {
log.Fatal("Unable to open config JSON file: ", err) log.Fatal("Unable to open config JSON file: ", err)
} }
defer file.Close() defer func(file *os.File) {
err := file.Close()
if err != nil {
log.Fatal("Unable to close config file: ", err)
}
}(file)
// Decode json config file to Configuration struct named config // Decode json config file to Configuration struct named config
decoder := json.NewDecoder(file) decoder := json.NewDecoder(file)