Remove usages of io.ReadFile and os.WriteFile to be compatible with 1.15
This commit is contained in:
+3
-3
@@ -15,7 +15,7 @@ package core
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -37,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 := io.ReadAll(f)
|
jsonBytes, err := ioutil.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)
|
||||||
@@ -72,7 +72,7 @@ func (d *FullData) WriteJSON(dataPath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.WriteFile(path, jsonBytes, 0666)
|
err = ioutil.WriteFile(path, jsonBytes, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -12,6 +12,7 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -116,7 +117,7 @@ Watching these pages for any changes that occur.
|
|||||||
=> https://git.nytpu.com/comitium/about/ aggregated using comitium
|
=> https://git.nytpu.com/comitium/about/ aggregated using comitium
|
||||||
`
|
`
|
||||||
|
|
||||||
err := os.WriteFile(path, []byte(rawPage), 0666)
|
err := ioutil.WriteFile(path, []byte(rawPage), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -161,7 +162,7 @@ func (d *FullData) WriteFeed(dataPath string) error {
|
|||||||
=> https://git.nytpu.com/comitium/about/ aggregated using comitium
|
=> https://git.nytpu.com/comitium/about/ aggregated using comitium
|
||||||
`
|
`
|
||||||
|
|
||||||
err := os.WriteFile(path, []byte(rawPage), 0666)
|
err := ioutil.WriteFile(path, []byte(rawPage), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user