From d8f3f85fb7688b5eb58e2495df288822f1aea5f1 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 19 Aug 2022 15:01:31 +0200 Subject: [PATCH] fix: replace depracted io/ioutil package with os package --- pkg/modules/api/formdata.go | 4 ++-- pkg/modules/chromium/chromium.go | 3 +-- pkg/modules/chromium/routes.go | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/modules/api/formdata.go b/pkg/modules/api/formdata.go index 0f63f3b3..5c45a246 100644 --- a/pkg/modules/api/formdata.go +++ b/pkg/modules/api/formdata.go @@ -2,8 +2,8 @@ package api import ( "fmt" - "io/ioutil" "net/http" + "os" "path/filepath" "sort" "strconv" @@ -426,7 +426,7 @@ func (form *FormData) mandatoryPath(filename string, target *string) *FormData { // readFile binds the content of a file to a string variable. It populates an // error if it fails to read the file content. func (form *FormData) readFile(path, filename string, target *string) *FormData { - b, err := ioutil.ReadFile(path) + b, err := os.ReadFile(path) if err != nil { form.append( fmt.Errorf("form file '%s' is invalid (%w)", filename, err), diff --git a/pkg/modules/chromium/chromium.go b/pkg/modules/chromium/chromium.go index d0b7ba21..29e0cf60 100644 --- a/pkg/modules/chromium/chromium.go +++ b/pkg/modules/chromium/chromium.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" "regexp" "strings" @@ -808,7 +807,7 @@ func (mod Chromium) PDF(ctx context.Context, logger *zap.Logger, URL, outputPath return fmt.Errorf("%v: %w", consoleExceptions, ErrConsoleExceptions) } - err = ioutil.WriteFile(outputPath, buffer, 0600) + err = os.WriteFile(outputPath, buffer, 0600) if err != nil { return fmt.Errorf("write result to output path: %w", err) } diff --git a/pkg/modules/chromium/routes.go b/pkg/modules/chromium/routes.go index 6b1e8b03..0217e0fe 100644 --- a/pkg/modules/chromium/routes.go +++ b/pkg/modules/chromium/routes.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "html/template" - "io/ioutil" "net/http" "os" "path/filepath" @@ -271,7 +270,7 @@ func convertMarkdownRoute(chromium API, engine gotenberg.PDFEngine) api.Route { return "", nil } - b, err := ioutil.ReadFile(path) + b, err := os.ReadFile(path) if err != nil { return "", fmt.Errorf("read markdown file '%s': %w", filename, err) }