1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 03:50:51 +00:00

close fs only when fs open without error

panic when close nil filesystem
This commit is contained in:
Ying Zou 2018-11-28 08:55:20 +08:00
parent b0e2bbce2a
commit a5a2471f2c

View File

@ -186,13 +186,13 @@ func BuildTemplate(dir string, files ...string) error {
var err error
fs := beeTemplateFS()
f, err := fs.Open(dir)
defer f.Close()
if err != nil {
if os.IsNotExist(err) {
return nil
}
return errors.New("dir open err")
}
defer f.Close()
beeTemplates, ok := beeViewPathTemplates[dir]
if !ok {