mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 17:10:54 +00:00
close fs only when fs open without error
panic when close nil filesystem
This commit is contained in:
parent
b0e2bbce2a
commit
a5a2471f2c
@ -186,13 +186,13 @@ func BuildTemplate(dir string, files ...string) error {
|
|||||||
var err error
|
var err error
|
||||||
fs := beeTemplateFS()
|
fs := beeTemplateFS()
|
||||||
f, err := fs.Open(dir)
|
f, err := fs.Open(dir)
|
||||||
defer f.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("dir open err")
|
return errors.New("dir open err")
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
beeTemplates, ok := beeViewPathTemplates[dir]
|
beeTemplates, ok := beeViewPathTemplates[dir]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user