dsqdpn31467
2014-07-15 06:05
浏览 248
已采纳

Golang template.ParseFiles“不是目录”错误

I'm trying to render just one template:

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
}

but I have the error not a directory. My exist function:

func exist(file_path string) bool {
    if _, err := os.Stat(file_path); os.IsNotExist(err) {
        return false
    }

    return true
}

it returns true. What's the problem with template.ParseFiles? I see documentation and where written that arguments are filenames and There must be at least one file. What I doing wrong?

EDITED: My variables:

root_path: /home/cnaize/Dropbox/develop/gocode/bin/advorts
template_path: /home/cnaize/Dropbox/develop/gocode/bin/advorts/app/views/mailtemplates/feedback.html

My file's content:

<html>
    <head>
    </head>
    <body>
        Hello, World!
    </body>
</html>

EDITED 2: I've moved all my projects, libs and etc to /home/cnaize/gocode and now I have error:

open /home/cnaize/gocode/bin/advorts/app/views/mailtemplates/feedback.txt: not a directory

Is it Revel's problem? What I supposed to do? I've tried to remove this bin file, didn't helped.

1条回答 默认 最新

相关推荐 更多相似问题