stop using ioutil

This commit is contained in:
nytpu
2021-03-18 16:10:37 -06:00
parent f9f6a99094
commit c3f5f7c682
+2 -3
View File
@@ -16,7 +16,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"sync" "sync"
@@ -38,7 +37,7 @@ func Init(dataPath string) error {
fi, err := f.Stat() fi, err := f.Stat()
if err == nil && fi.Size() > 0 { if err == nil && fi.Size() > 0 {
// File is not empty // File is not empty
jsonBytes, err := ioutil.ReadAll(f) jsonBytes, err := io.ReadAll(f)
f.Close() f.Close()
if err != nil { if err != nil {
return fmt.Errorf("read comitium.json error: %w", err) return fmt.Errorf("read comitium.json error: %w", err)
@@ -73,7 +72,7 @@ func (d *FullData) WriteJSON(dataPath string) error {
if err != nil { if err != nil {
return err return err
} }
err = ioutil.WriteFile(path, jsonBytes, 0666) err = os.WriteFile(path, jsonBytes, 0666)
if err != nil { if err != nil {
return err return err
} }