tree-wide: rewrite ioutil functions to their replacements
The ioutil package has been deprecated in Go 1.16 [1]. This CL removes
all our own users of that package and rewrites them to use their
replacements in the os package. I initially wanted to do this with a
gofix but because all replacements were signature-compatible I just
did it with a few string replaces and then ran goimports to fix up the
imports.
I intentionally didn't rewrite the patches as that would require a
different process and is IMO of less value.
[1] https://github.com/golang/go/issues/42026
Change-Id: Iac6663a1f1ee49f9b1c6e4b3d97e73f2c3b54a13
Reviewed-on: https://review.monogon.dev/c/monogon/+/449
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/intellij/localconfig/watchers/filewatchers.go b/intellij/localconfig/watchers/filewatchers.go
index dd1810c..4a56161 100644
--- a/intellij/localconfig/watchers/filewatchers.go
+++ b/intellij/localconfig/watchers/filewatchers.go
@@ -19,7 +19,6 @@
import (
"encoding/xml"
"fmt"
- "io/ioutil"
"os"
"path"
)
@@ -67,7 +66,7 @@
}
func readConfig(filename string) (cfg *config, err error) {
- b, err := ioutil.ReadFile(filename)
+ b, err := os.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("failed reading file: %w", err)
}
@@ -90,7 +89,7 @@
// (but not applies) instantly.
tmpPath := filename + ".tmp"
defer os.Remove(tmpPath)
- if err := ioutil.WriteFile(tmpPath, []byte(xml.Header+string(b)), 0664); err != nil {
+ if err := os.WriteFile(tmpPath, []byte(xml.Header+string(b)), 0664); err != nil {
return fmt.Errorf("failed to write: %w", err)
}
if err := os.Rename(tmpPath, filename); err != nil {