mirror of
https://github.com/kovetskiy/mark.git
synced 2026-04-21 13:52:34 +00:00
Replace deprecated io/ioutils (#230)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user