Skip to content

Commit 48d48ee

Browse files
committed
As of Go 1.16, ioutil.ReadAll is deprecated and simply calls io.ReadAll
See #58 (comment)
1 parent 7e3a25c commit 48d48ee

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

cmd/md2pdf/md2pdf.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"errors"
55
"flag"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"log"
99
"net/http"
1010
"os"
@@ -47,7 +47,7 @@ func processRemoteInputFile(url string) ([]byte, error) {
4747
if resp.StatusCode != 200 {
4848
return nil, errors.New("Received non 200 response code: " + fmt.Sprintf("HTTP %d", resp.StatusCode))
4949
}
50-
content, rerr := ioutil.ReadAll(resp.Body)
50+
content, rerr := io.ReadAll(resp.Body)
5151
return content, rerr
5252
}
5353

@@ -94,7 +94,7 @@ func main() {
9494
var err error
9595
var inputBaseURL string
9696
if *input == "" {
97-
content, err = ioutil.ReadAll(os.Stdin)
97+
content, err = io.ReadAll(os.Stdin)
9898
if err != nil {
9999
log.Fatal(err)
100100
}
@@ -121,7 +121,7 @@ func main() {
121121
log.Fatal(err)
122122
}
123123
for i, filePath := range files {
124-
fileContents, err := ioutil.ReadFile(filePath)
124+
fileContents, err := os.ReadFile(filePath)
125125
if err != nil {
126126
log.Fatal(err)
127127
}
@@ -131,7 +131,7 @@ func main() {
131131
}
132132
}
133133
} else {
134-
content, err = ioutil.ReadFile(*input)
134+
content, err = os.ReadFile(*input)
135135
if err != nil {
136136
log.Fatal(err)
137137
}

mdtopdf_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package mdtopdf
2121

2222
import (
23-
"io/ioutil"
23+
"os"
2424
"path"
2525
"strings"
2626
"testing"
@@ -36,7 +36,7 @@ func testit(inputf string, gohighlight bool, t *testing.T) {
3636
pdffile := path.Join(inputd, strings.TrimSuffix(path.Base(input), ".text"))
3737
pdffile += ".pdf"
3838

39-
content, err := ioutil.ReadFile(input)
39+
content, err := os.ReadFile(input)
4040
if err != nil {
4141
t.Errorf("%v:%v", input, err)
4242
}

nodeProcessing.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"errors"
2424
"fmt"
2525
"io"
26-
"io/ioutil"
2726
"log"
2827
"net/http"
2928
"os"
@@ -120,7 +119,7 @@ func (r *PdfRenderer) processCodeblock(node ast.CodeBlock) {
120119
if strings.HasPrefix(string(node.Literal), "<script") && string(node.Info) == "html" {
121120
node.Info = []byte("javascript")
122121
}
123-
syntaxFile, lerr := ioutil.ReadFile(r.SyntaxHighlightBaseDir + "/" + string(node.Info) + ".yaml")
122+
syntaxFile, lerr := os.ReadFile(r.SyntaxHighlightBaseDir + "/" + string(node.Info) + ".yaml")
124123
if lerr != nil {
125124
r.outputUnhighlightedCodeBlock(string(node.Literal))
126125
return
@@ -393,7 +392,7 @@ func (r *PdfRenderer) processImage(node ast.Image, entering bool) {
393392
mtype, err := mimetype.DetectFile(destination)
394393
if mtype.Is("image/svg+xml") {
395394
re := regexp.MustCompile(`<svg\s*.*\s*width="([0-9\.]+)"\sheight="([0-9\.]+)".*>`)
396-
contents, _ := ioutil.ReadFile(destination)
395+
contents, _ := os.ReadFile(destination)
397396
matches := re.FindStringSubmatch(string(contents))
398397
tf, err := os.CreateTemp(tempDir, "*.svg")
399398
if err != nil {

0 commit comments

Comments
 (0)