Skip to content

Commit

Permalink
fix(config/parser.go): correct unlocking on error paths
Browse files Browse the repository at this point in the history
Spotted while reading the code.
  • Loading branch information
bassosimone committed Jul 24, 2020
1 parent fc58c4d commit 72e3044
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ 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")
}
if err := ioutil.WriteFile(c.path, configJSON, 0644); err != nil {
return errors.Wrap(err, "writing config JSON")
}
c.Unlock()
return nil
}

Expand Down

0 comments on commit 72e3044

Please sign in to comment.