Templates “Golang template.ParseFiles”;“不是目录”;错误
我尝试只渲染一个模板:Templates “Golang template.ParseFiles”;“不是目录”;错误,templates,go,revel,Templates,Go,Revel,我尝试只渲染一个模板: root_path, err := osext.Executable() if err != nil { return err } template_path := root_path + "/app/views/mailtemplates/" + "feedback.html" fmt.Println(exist(template_path)) tmpl, err := template.ParseFiles(template_path) if err !=
root_path, err := osext.Executable()
if err != nil {
return err
}
template_path := root_path + "/app/views/mailtemplates/" + "feedback.html"
fmt.Println(exist(template_path))
tmpl, err := template.ParseFiles(template_path)
if err != nil {
return err
}
但是我有一个错误不是目录
。
我的存在
功能:
func exist(file_path string) bool {
if _, err := os.Stat(file_path); os.IsNotExist(err) {
return false
}
return true
}
它返回true
。template.ParseFiles
有什么问题?我看到了文档,其中的参数是文件名
,并且必须至少有一个文件
。我做错了什么
编辑:
我的变量:
root_path: /home/cnaize/Dropbox/develop/gocode/bin/advorts
template_path: /home/cnaize/Dropbox/develop/gocode/bin/advorts/app/views/mailtemplates/feedback.html
我的文件内容:
<html>
<head>
</head>
<body>
Hello, World!
</body>
</html>
这是Revel的问题吗?我该怎么办?我试图删除这个bin文件,没有帮助。 实际问题是在
将文件放在Dropbox路径之外可以解决这个问题。你能发布
osext.Executable()
和模板路径的输出吗?我已经更新了我的帖子。我不知道这里面有什么不对template@cnaize如果您的路径由dropbox管理,您是否可以尝试在dropbox之外的一个更简单的路径中使用一个文件进行测试?像/home/cnaize/feedback.html
thx!它是如何工作的!我不知道Dropbox有什么问题folder@cnaize好的,我已经编辑了答案以反映实际问题。我已经更新了我的帖子,现在我的bin文件有问题,你能帮我吗?
open /home/cnaize/gocode/bin/advorts/app/views/mailtemplates/feedback.txt: not a directory