From 3d47cd0a400757b34f14911279897c14f65f586b Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 21 Mar 2013 20:46:54 +0800 Subject: [PATCH] add just wheather the view is a dir --- template.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/template.go b/template.go index 3e0df9a8..bfafe289 100644 --- a/template.go +++ b/template.go @@ -196,11 +196,18 @@ 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") + } self := templatefile{ root: dir, files: make(map[string][]string), } - err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error { + err = filepath.Walk(dir, func(path string, f os.FileInfo, err error) error { return self.visit(path, f, err) }) if err != nil {