Remove deprecated io/ioutil import and calls
This commit is contained in:
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -20,7 +19,7 @@ var (
|
||||
|
||||
func topWrapper(r *http.Request) string {
|
||||
defer log.PanicSafe()
|
||||
headerTemplate, err := ioutil.ReadFile("./static/header.tpl")
|
||||
headerTemplate, err := os.ReadFile("./static/header.tpl")
|
||||
if err != nil {
|
||||
log.LogError(fmt.Sprintf("Unable to open header template: ```%+v```", err))
|
||||
return ""
|
||||
@ -37,7 +36,7 @@ func topWrapper(r *http.Request) string {
|
||||
|
||||
func bodyWrapper(r *http.Request, template string) string {
|
||||
defer log.PanicSafe()
|
||||
bodyTemplate, err := ioutil.ReadFile(fmt.Sprintf("./static/%+v.tpl", template))
|
||||
bodyTemplate, err := os.ReadFile(fmt.Sprintf("./static/%+v.tpl", template))
|
||||
if err != nil {
|
||||
log.LogError(fmt.Sprintf("Attempt to load %s.tpl failed. ```%+v```", template, err))
|
||||
return bodyWrapper(r, "404")
|
||||
@ -58,7 +57,7 @@ func greetUser(w http.ResponseWriter, r *http.Request) {
|
||||
loggedIn, _ := detectUser(r, "Homepage")
|
||||
|
||||
if loggedIn {
|
||||
bodyTemplate, _ := ioutil.ReadFile("./static/index.html")
|
||||
bodyTemplate, _ := os.ReadFile("./static/index.html")
|
||||
fmt.Fprint(w, string(bodyTemplate))
|
||||
} else {
|
||||
fmt.Fprint(w, pageBuilder(r, "home"))
|
||||
@ -103,7 +102,7 @@ func notFoundPage(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
func card(title string, content string, footer string) string {
|
||||
defer log.PanicSafe()
|
||||
cardTemplate, err := ioutil.ReadFile("./static/card.tpl")
|
||||
cardTemplate, err := os.ReadFile("./static/card.tpl")
|
||||
if err != nil {
|
||||
log.LogError("Unable to open card template")
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user