Replace deprecated io/ioutils (#230)

This commit is contained in:
Manuel Rüger
2023-01-03 18:54:04 +01:00
committed by GitHub
parent f4bbbb19ca
commit 3e558ac2e3
8 changed files with 17 additions and 20 deletions

View File

@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
@@ -727,7 +726,7 @@ func newErrorStatusNotOK(request *gopencils.Resource) error {
)
}
output, _ := ioutil.ReadAll(request.Raw.Body)
output, _ := io.ReadAll(request.Raw.Body)
defer request.Raw.Body.Close()
return fmt.Errorf(

View File

@@ -42,7 +42,7 @@ func ResolveAttachments(
return nil, err
}
for i, _ := range attaches {
for i := range attaches {
checksum, err := getChecksum(attaches[i].Path)
if err != nil {
return nil, karma.Format(
@@ -147,7 +147,7 @@ func ResolveAttachments(
updating[i] = attach
}
for i, _ := range existing {
for i := range existing {
log.Infof(nil, "keeping unmodified attachment: %q", attaches[i].Name)
}

View File

@@ -3,7 +3,7 @@ package includes
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
@@ -16,8 +16,9 @@ import (
)
// <!-- Include: <template path>
// (Delims: (none | "<left>","<right>"))?
// <optional yaml data> -->
//
// (Delims: (none | "<left>","<right>"))?
// <optional yaml data> -->
var reIncludeDirective = regexp.MustCompile(
`(?s)` +
`<!--\s*Include:\s*(?P<template>.+?)\s*` +
@@ -43,7 +44,7 @@ func LoadTemplate(
var body []byte
body, err := ioutil.ReadFile(filepath.Join(base, path))
body, err := os.ReadFile(filepath.Join(base, path))
if err != nil {
err = facts.Format(
err,

View File

@@ -3,7 +3,6 @@ package mark
import (
"bytes"
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"
@@ -80,7 +79,7 @@ func resolveLink(
return "", nil
}
linkContents, err := ioutil.ReadFile(filepath)
linkContents, err := os.ReadFile(filepath)
if err != nil {
return "", karma.Format(err, "read file: %s", filepath)
}

View File

@@ -1,7 +1,7 @@
package mark
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
@@ -31,11 +31,11 @@ func TestCompileMarkdown(t *testing.T) {
testname := strings.TrimSuffix(basename, ".md")
htmlname := filepath.Join(filepath.Dir(filename), testname+".html")
markdown, err := ioutil.ReadFile(filename)
markdown, err := os.ReadFile(filename)
if err != nil {
panic(err)
}
html, err := ioutil.ReadFile(htmlname)
html, err := os.ReadFile(htmlname)
if err != nil {
panic(err)
}
@@ -52,7 +52,7 @@ func TestCompileMarkdown(t *testing.T) {
func TestExtractDocumentLeadingH1(t *testing.T) {
filename := "testdata/header.md"
markdown, err := ioutil.ReadFile(filename)
markdown, err := os.ReadFile(filename)
if err != nil {
panic(err)
}