From 3db3692f1bc0cfc09f2e003241052132f9c80f94 Mon Sep 17 00:00:00 2001 From: Sven Wiltink Date: Wed, 9 Oct 2024 13:33:53 +0200 Subject: [PATCH] truncate config file when writing Not truncating the file causes invalid json because of shorter writes --- config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.go b/config.go index abe775c..db74b69 100644 --- a/config.go +++ b/config.go @@ -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 }