mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Remove deprecated io/ioutil package
Miniflux now requires at least Go 1.16 and io/util is deprecated. https://golang.org/doc/go1.16#ioutil
This commit is contained in:
parent
713d575bad
commit
a352aff93b
16 changed files with 26 additions and 36 deletions
|
@ -7,7 +7,6 @@ package encoding // import "miniflux.app/reader/encoding"
|
|||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"unicode/utf8"
|
||||
|
||||
"golang.org/x/net/html/charset"
|
||||
|
@ -25,7 +24,7 @@ import (
|
|||
// - Feeds with encoding specified only in XML document and not in HTTP header
|
||||
// - Feeds with wrong encoding defined and already in UTF-8
|
||||
func CharsetReader(label string, input io.Reader) (io.Reader, error) {
|
||||
buffer, _ := ioutil.ReadAll(input)
|
||||
buffer, _ := io.ReadAll(input)
|
||||
r := bytes.NewReader(buffer)
|
||||
|
||||
// The document is already UTF-8, do not do anything (avoid double-encoding).
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"miniflux.app/config"
|
||||
|
@ -104,7 +103,7 @@ func downloadIcon(iconURL string, fetchViaProxy bool) (*model.Icon, error) {
|
|||
return nil, fmt.Errorf("unable to download icon: status=%d", response.StatusCode)
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(response.Body)
|
||||
body, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read downloaded icon: %v", err)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ package parser // import "miniflux.app/reader/parser"
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"miniflux.app/http/client"
|
||||
|
@ -329,7 +329,7 @@ func TestDifferentEncodingWithResponse(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range unicodeTestCases {
|
||||
content, err := ioutil.ReadFile("testdata/" + tc.filename)
|
||||
content, err := os.ReadFile("testdata/" + tc.filename)
|
||||
if err != nil {
|
||||
t.Fatalf(`Unable to read file %q: %v`, tc.filename, err)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ package scraper // import "miniflux.app/reader/scraper"
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
@ -54,7 +54,7 @@ func TestSelectorRules(t *testing.T) {
|
|||
}
|
||||
|
||||
for filename, rule := range ruleTestCases {
|
||||
html, err := ioutil.ReadFile("testdata/" + filename)
|
||||
html, err := os.ReadFile("testdata/" + filename)
|
||||
if err != nil {
|
||||
t.Fatalf(`Unable to read file %q: %v`, filename, err)
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func TestSelectorRules(t *testing.T) {
|
|||
t.Fatalf(`Scraping error for %q - %q: %v`, filename, rule, err)
|
||||
}
|
||||
|
||||
expectedResult, err := ioutil.ReadFile("testdata/" + filename + "-result")
|
||||
expectedResult, err := os.ReadFile("testdata/" + filename + "-result")
|
||||
if err != nil {
|
||||
t.Fatalf(`Unable to read file %q: %v`, filename, err)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"miniflux.app/reader/encoding"
|
||||
|
@ -18,7 +17,7 @@ import (
|
|||
// NewDecoder returns a XML decoder that filters illegal characters.
|
||||
func NewDecoder(data io.Reader) *xml.Decoder {
|
||||
var decoder *xml.Decoder
|
||||
buffer, _ := ioutil.ReadAll(data)
|
||||
buffer, _ := io.ReadAll(data)
|
||||
enc := procInst("encoding", string(buffer))
|
||||
if enc != "" && enc != "utf-8" && enc != "UTF-8" && !strings.EqualFold(enc, "utf-8") {
|
||||
// filter invalid chars later within decoder.CharsetReader
|
||||
|
@ -36,7 +35,7 @@ func NewDecoder(data io.Reader) *xml.Decoder {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rawData, err := ioutil.ReadAll(utf8Reader)
|
||||
rawData, err := io.ReadAll(utf8Reader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to read data: %q", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue