Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates “Golang template.ParseFiles”;“不是目录”;错误_Templates_Go_Revel - Fatal编程技术网

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 /< /C>文件夹中的一个路径:考虑它是由外部进程同步的/管理的(<代码> Dropbox < /代码>),访问文件的能力并不总是可靠的。
将文件放在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