Skip to content

Commit 9436125

Browse files
authored
use O_TRUNC instead of Truncate
1 parent 84090cd commit 9436125

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

internal/config/settings.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,11 @@ func InitLocalSettings(settings map[string]interface{}, path string) {
313313
}
314314

315315
func WriteJson(filename string, v interface{}) error {
316-
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0644)
316+
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
317317
if err != nil {
318318
return err
319319
}
320320
defer file.Close()
321-
file.Truncate(0)
322321
enc := json.NewEncoder(file)
323322
enc.SetEscapeHTML(false)
324323
enc.SetIndent("", " ")

0 commit comments

Comments
 (0)