So im just trying to load a html file on the webpage.
tmpl, err := template.ParseFiles("/templates/main.html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// Execute the template with the data
err = tmpl.Execute(w, data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
But i get error “open /templates/main.html: System could not find path.
But i have the /templates/main.html in main go path.
I was expecting to load the html file.
New contributor
Branduil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.