From 9480ffcdc01dbc5c0e1b5fa1d831c31a40a361e1 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 27 Apr 2020 17:07:00 +0800 Subject: [PATCH] improve function SetPath/AddPath for package gview --- os/gview/gview_config.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/os/gview/gview_config.go b/os/gview/gview_config.go index 6f1a08ac2..5a1eb184c 100644 --- a/os/gview/gview_config.go +++ b/os/gview/gview_config.go @@ -95,8 +95,13 @@ func (view *View) SetConfigWithMap(m map[string]interface{}) error { // SetPath sets the template directory path for template file search. // The parameter can be absolute or relative path, but absolute path is suggested. func (view *View) SetPath(path string) error { - isDir := false - realPath := "" + var ( + isDir = false + realPath = "" + ) + if path == "" { + path = "." + } if file := gres.Get(path); file != nil { realPath = path isDir = file.FileInfo().IsDir() @@ -147,8 +152,13 @@ func (view *View) SetPath(path string) error { // AddPath adds a absolute or relative path to the search paths. func (view *View) AddPath(path string) error { - isDir := false - realPath := "" + var ( + isDir = false + realPath = "" + ) + if path == "" { + path = "." + } if file := gres.Get(path); file != nil { realPath = path isDir = file.FileInfo().IsDir()