Go, ошибка в рендере шаблона html бэкенда

введите сюда описание изображения

Ошибка возниает при подключении к порту.

main.go

package main
import (
    "fmt"
    "net/http"
    "text/template"
)
const ADRESS_PORT = "127.0.0.1:3335"
// Home is the home page handler
func Home(w http.ResponseWriter, r *http.Request) {
    renderTemplate(w, "home_page.html")
}
// About is the about page handler
func About(w http.ResponseWriter, r *http.Request) {
    renderTemplate(w, "about_page.html")
}
func renderTemplate(w http.ResponseWriter, tmpl string) {
    parsedTemplate, _ := template.ParseFiles("./templates/" + tmpl)
    err := parsedTemplate.Execute(w, nil)
    if err != nil {
        fmt.Println("error parsing template:", err)
        return
    }
}
// Main is the main application function
func main() {
    http.HandleFunc("/", Home)
    http.HandleFunc("/about", About)
    fmt.Printf(fmt.Sprintf("Starting application on adress %s", ADRESS_PORT))
    _ = http.ListenAndServe(ADRESS_PORT, nil)
}

TERMINAL

http: panic serving 127.0.0.1:56824: runtime error: invalid memory address or nil pointer dereference

введите сюда описание изображения


Ответы (0 шт):