Skip to content

Commit

Permalink
Merge pull request #58 from nerdalize/fix-conf_pretty
Browse files Browse the repository at this point in the history
Pretty write config file
  • Loading branch information
borismattijssen committed Mar 30, 2017
2 parents 30c84d3 + 88665ad commit 67ccf75
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nerd/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ func Write() error {
if err != nil {
return errors.Wrap(err, "failed to read config")
}
data, err := json.Marshal(c)
f, err := os.Create(loc)
if err != nil {
return errors.Wrap(err, "failed to encode json")
return errors.Wrap(err, "failed to create/open config file")
}
err = ioutil.WriteFile(loc, data, 0644)
enc := json.NewEncoder(f)
enc.SetIndent("", "\t")
err = enc.Encode(c)
if err != nil {
return errors.Wrap(err, "failed to write to config file")
return errors.Wrap(err, "failed to encode json")
}
return nil
}
Expand Down

0 comments on commit 67ccf75

Please sign in to comment.