Golang中没有这样的文件或目录错误

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

I have solved the issue by giving absolute path of the html. For that I created a class in which the html are parsed

package htmltemplates

import (
"html/template"
"path/filepath"
)

And in the NewHandler method I removed //Templates is used to store all Templates var Templates *template.Template

func init() {
filePrefix, _ := filepath.Abs("./work/src/Project/view/html/")       // path from the working directory
Templates = template.Must(template.ParseFiles(filePrefix + "/first.html")) 
...
//htmls must be specified here to parse it
}

And in the NewHandler I removed first 5 lines and instead gave

err := htmltemplates.Templates.ExecuteTemplate(w, "first.html", nil)

It is now working .But need a better solution if any

Have you included this line in the main function?

http.Handle("/view/", http.StripPrefix("/view/", http.FileServer(http.Dir("view"))))

view is the name of the directory that has to be specified in FileServer function to allow read/write.(view directory has to be kept in the same directory where your binary is present)

Better solution is to give absolute path name i.e instead of this "view/html/first.html",try this

 func NewHandler(w http.ResponseWriter, r *http.Request) {
        t, err := template.ParseFiles("./work/src/Project/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, "")
    }