From 007830ab33505441c96ac10e13ee25232fe3c4bf Mon Sep 17 00:00:00 2001 From: Maximilian Date: Wed, 14 Dec 2022 15:23:48 -0600 Subject: [PATCH] Log error when failing to close the config file --- config/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 6199678..d700da1 100644 --- a/config/config.go +++ b/config/config.go @@ -35,7 +35,12 @@ func LoadConfig() Configuration { 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 decoder := json.NewDecoder(file)