Move defer after checking error

This commit is contained in:
Thomas Roehl 2022-01-30 22:05:27 +01:00
parent 011218ab80
commit 3e329c3324

View File

@ -33,11 +33,11 @@ type CentralConfigFile struct {
func LoadCentralConfiguration(file string, config *CentralConfigFile) error {
configFile, err := os.Open(file)
defer configFile.Close()
if err != nil {
cclog.Error(err.Error())
return err
}
defer configFile.Close()
jsonParser := json.NewDecoder(configFile)
err = jsonParser.Decode(config)
return err