From d0e171c801bdbcad02e127c1aa123c36a8112d11 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 21 Mar 2013 21:45:48 +0800 Subject: [PATCH] add exist --- template.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/template.go b/template.go index bfafe289..8f52710f 100644 --- a/template.go +++ b/template.go @@ -196,12 +196,12 @@ func AddTemplateExt(ext string) { } func BuildTemplate(dir string) error { - f, err := os.Stat(dir) - if err != nil { - return err - } - if !f.IsDir() { - return errors.New("is not dir") + if _, err := os.Stat(dir); err != nil { + if os.IsNotExist(err) { + return err + } else { + return errors.New("dir open err") + } } self := templatefile{ root: dir,