From 1983672e3c1a1bf5101035059518d2c4567b244f Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Fri, 24 Jul 2020 17:12:51 +0200 Subject: [PATCH] fix(config/parser.go): correct unlocking on error paths (#146) Spotted while reading the code. --- config/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/parser.go b/config/parser.go index 7a36ea6..3bd5da2 100644 --- a/config/parser.go +++ b/config/parser.go @@ -69,6 +69,7 @@ type Config struct { // Write the config file in json to the path func (c *Config) Write() error { c.Lock() + defer c.Unlock() configJSON, _ := json.MarshalIndent(c, "", " ") if c.path == "" { return errors.New("config file path is empty") @@ -76,7 +77,6 @@ func (c *Config) Write() error { if err := ioutil.WriteFile(c.path, configJSON, 0644); err != nil { return errors.Wrap(err, "writing config JSON") } - c.Unlock() return nil }