replace deprecated ioutils
This commit is contained in:
parent
a14bc1b5ee
commit
5a891c8207
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue