improve function SetPath/AddPath for package gview

This commit is contained in:
John
2020-04-27 17:07:00 +08:00
parent 5db10add4a
commit 9480ffcdc0

View File

@ -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 <path> 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()