From 5c9827926b22c1fa00b5c654b50979c594d63c9d Mon Sep 17 00:00:00 2001 From: Kayra Date: Wed, 17 Apr 2024 20:40:21 +0300 Subject: [PATCH] close file after we're done --- api/server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/server.go b/api/server.go index d0c783b..386b7d7 100644 --- a/api/server.go +++ b/api/server.go @@ -45,9 +45,15 @@ func ValidateConfigFile(filePath string) (Config, error) { if err != nil { return config, errors.Join(validationErr, err) } - if _, err := os.OpenFile(c.DBPath, os.O_CREATE|os.O_RDONLY, 0644); err != nil { + dbfile, err := os.OpenFile(c.DBPath, os.O_CREATE|os.O_RDONLY, 0644) + if err != nil { return config, errors.Join(validationErr, err) } + err = dbfile.Close() + if err != nil { + return config, errors.Join(validationErr, err) + } + config.Cert = cert config.Key = key config.DBPath = c.DBPath