Skip to content

Commit

Permalink
truncate config file when writing
Browse files Browse the repository at this point in the history
Not truncating the file causes invalid json because of shorter writes
  • Loading branch information
svenwiltink committed Oct 9, 2024
1 parent 4f3a0fc commit 3db3692
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func configFromBytes(data []byte) (configuration, error) {
}

func saveConfig(config configuration) error {
f, err := os.OpenFile("config.json", os.O_WRONLY, 0o644)
f, err := os.OpenFile("config.json", os.O_WRONLY|os.O_TRUNC, 0o644)
if err != nil {
return err
}
Expand Down

0 comments on commit 3db3692

Please sign in to comment.