我正在尝试只渲染一个模板:
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
}
但我有错误not a directory
。我的exist
功能:
func exist(file_path string) bool {
if _, err := os.Stat(file_path); os.IsNotExist(err) {
return false
}
return true
}
它返回true
。有什么问题template.ParseFiles
?我看到了文档,并且在哪里写了论点filenames
和There must be at least one file
. 我做错了什么?
编辑: 我的变量:
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>
编辑2:我已经将我所有的项目、库等移到了/home/cnaize/gocode
,现在我有错误:
open /home/cnaize/gocode/bin/advorts/app/views/mailtemplates/feedback.txt: not a directory
是Revel
问题吗?我该怎么办?我试图删除这个 bin 文件,没有帮助。