Skip to content

Commit

Permalink
use O_TRUNC instead of Truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias314 committed Dec 11, 2024
1 parent e4dcb28 commit 902ff87
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,11 @@ func InitLocalSettings(settings map[string]interface{}, path string) {
}

func WriteJson(filename string, v interface{}) error {
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0644)
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return err
}
defer file.Close()
file.Truncate(0)
enc := json.NewEncoder(file)
enc.SetEscapeHTML(false)
enc.SetIndent("", " ")
Expand Down

0 comments on commit 902ff87

Please sign in to comment.