From 24d4a278427159811fa83ff9fa6de504f01c86a6 Mon Sep 17 00:00:00 2001 From: Eyal Post Date: Mon, 13 Mar 2017 08:46:57 +0200 Subject: [PATCH] Don't panic during AddViewPath if adding the same path twice --- template.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/template.go b/template.go index 2dba9d1f..0524f3cb 100644 --- a/template.go +++ b/template.go @@ -72,7 +72,7 @@ func ExecuteViewPathTemplate(wr io.Writer, name string, viewPath string, data in } panic("can't find templatefile in the path:" + viewPath + "/" + name) } - panic("Uknown view path:" + viewPath) + panic("Unknown view path:" + viewPath) } func init() { @@ -165,6 +165,9 @@ func AddTemplateExt(ext string) { //will panic if called after beego.Run() func AddViewPath(viewPath string) error { if beeViewPathTemplateLocked { + if _, exist := beeViewPathTemplates[viewPath]; exist { + return nil //Ignore if viewpath already exists + } panic("Can not add new view paths after beego.Run()") } beeViewPathTemplates[viewPath] = make(map[string]*template.Template)