replace deprecated ioutils

This commit is contained in:
Robert Kaussow 2022-08-05 13:10:24 +02:00
parent a14bc1b5ee
commit 5a891c8207
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
1 changed files with 4 additions and 3 deletions

View File

@ -8,9 +8,10 @@ package template
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"os"
"strings" "strings"
"github.com/flowchartsman/handlebars/v3" "github.com/flowchartsman/handlebars/v3"
@ -33,14 +34,14 @@ func Render(template string, payload interface{}) (s string, err error) {
defer res.Body.Close() defer res.Body.Close()
out, err := ioutil.ReadAll(res.Body) out, err := io.ReadAll(res.Body)
if err != nil { if err != nil {
return s, fmt.Errorf("failed to read: %w", err) return s, fmt.Errorf("failed to read: %w", err)
} }
template = string(out) template = string(out)
case "file": case "file":
out, err := ioutil.ReadFile(u.Path) out, err := os.ReadFile(u.Path)
if err != nil { if err != nil {
return s, fmt.Errorf("failed to read: %w", err) return s, fmt.Errorf("failed to read: %w", err)
} }