Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As of Go 1.16, ioutil.ReadAll is deprecated and simply calls io.ReadAll #60

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/md2pdf/md2pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -47,7 +47,7 @@ func processRemoteInputFile(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, errors.New("Received non 200 response code: " + fmt.Sprintf("HTTP %d", resp.StatusCode))
}
content, rerr := ioutil.ReadAll(resp.Body)
content, rerr := io.ReadAll(resp.Body)
return content, rerr
}

Expand Down Expand Up @@ -94,7 +94,7 @@ func main() {
var err error
var inputBaseURL string
if *input == "" {
content, err = ioutil.ReadAll(os.Stdin)
content, err = io.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}
Expand All @@ -121,7 +121,7 @@ func main() {
log.Fatal(err)
}
for i, filePath := range files {
fileContents, err := ioutil.ReadFile(filePath)
fileContents, err := os.ReadFile(filePath)
if err != nil {
log.Fatal(err)
}
Expand All @@ -131,7 +131,7 @@ func main() {
}
}
} else {
content, err = ioutil.ReadFile(*input)
content, err = os.ReadFile(*input)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions mdtopdf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package mdtopdf

import (
"io/ioutil"
"os"
"path"
"strings"
"testing"
Expand All @@ -36,7 +36,7 @@ func testit(inputf string, gohighlight bool, t *testing.T) {
pdffile := path.Join(inputd, strings.TrimSuffix(path.Base(input), ".text"))
pdffile += ".pdf"

content, err := ioutil.ReadFile(input)
content, err := os.ReadFile(input)
if err != nil {
t.Errorf("%v:%v", input, err)
}
Expand Down
5 changes: 2 additions & 3 deletions nodeProcessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -120,7 +119,7 @@ func (r *PdfRenderer) processCodeblock(node ast.CodeBlock) {
if strings.HasPrefix(string(node.Literal), "<script") && string(node.Info) == "html" {
node.Info = []byte("javascript")
}
syntaxFile, lerr := ioutil.ReadFile(r.SyntaxHighlightBaseDir + "/" + string(node.Info) + ".yaml")
syntaxFile, lerr := os.ReadFile(r.SyntaxHighlightBaseDir + "/" + string(node.Info) + ".yaml")
if lerr != nil {
r.outputUnhighlightedCodeBlock(string(node.Literal))
return
Expand Down Expand Up @@ -393,7 +392,7 @@ func (r *PdfRenderer) processImage(node ast.Image, entering bool) {
mtype, err := mimetype.DetectFile(destination)
if mtype.Is("image/svg+xml") {
re := regexp.MustCompile(`<svg\s*.*\s*width="([0-9\.]+)"\sheight="([0-9\.]+)".*>`)
contents, _ := ioutil.ReadFile(destination)
contents, _ := os.ReadFile(destination)
matches := re.FindStringSubmatch(string(contents))
tf, err := os.CreateTemp(tempDir, "*.svg")
if err != nil {
Expand Down
Loading