How to handle file path when i am accessing file from other go file than main.
in other.go file i am trying to run ParseFS but it's giving the template: pattern matches no files: templates/test.tmpl
error. Here is my file tree.
├── go.mod
├── main
│ └── main.go
└── other
├── other.go
└── templates
└── test.tmpl
other/other.go
package other
import (
"embed"
"fmt"
"html/template"
)
var templateFS embed.FS
func Check() error {
_, err := template.New("email").ParseFS(templateFS, "templates/"+ "test.tmpl")
if err != nil {
fmt.Println(err)
}
return nil
}
main/main.go
func main() {
err :=othher.Check()
if err != nil {
fmt.Println(err)
}
}