use fs facilities
The ioutil module was deprecated some years ago, so use the newer version of the same tools.
This commit is contained in:
parent
b06f25281f
commit
6f3e8d4772
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
@ -139,18 +138,15 @@ func main() {
|
|||||||
|
|
||||||
tmpl := template.New("main")
|
tmpl := template.New("main")
|
||||||
tmpl.Funcs(Funcs)
|
tmpl.Funcs(Funcs)
|
||||||
files, err := ioutil.ReadDir(config.TemplatePath)
|
files, err := os.ReadDir(config.TemplatePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("could not read directory '%s': %s", config.TemplatePath, err)
|
log.Fatalf("could not read directory '%s': %s", config.TemplatePath, err)
|
||||||
}
|
}
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if !file.Mode().IsRegular() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !strings.HasSuffix(file.Name(), ".html") {
|
if !strings.HasSuffix(file.Name(), ".html") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
raw, err := ioutil.ReadFile(path.Join(config.TemplatePath, file.Name()))
|
raw, err := os.ReadFile(path.Join(config.TemplatePath, file.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("could not read file '%s': %s", path.Join(config.TemplatePath, file.Name()), err)
|
log.Fatalf("could not read file '%s': %s", path.Join(config.TemplatePath, file.Name()), err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user