I want to specify an html template in one of my golang controller My directory structure is like this
Project
-com
-src
- controller
-contoller.go
-view
- html
-first.html
I want to load first.html for request /new .I have used NewHandler for url /new and the NewHandler func is executing when /new request comes and is in controller.go. Here is my code
func NewHandler(w http.ResponseWriter, r *http.Request) {
t, err := template.ParseFiles("view/html/first.html")
if err == nil {
log.Println("Template parsed successfully....")
}
err := templates.ExecuteTemplate(w, "view/html/first.html", nil)
if err != nil {
log.Println("Not Found template")
}
// t.Execute(w, "")
}
But I am getting an error
panic: open first.html: no such file or directory
Please help me to remove this error. Thanks in advance