This commit is contained in:
John Guo 2022-05-11 20:42:34 +08:00
parent 4bdaacab91
commit f6f0c8fd1e
2 changed files with 5 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/gogf/gf/v2/os/gcfg"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gres"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/util/gutil"
@ -59,8 +60,10 @@ func Test_View_Config(t *testing.T) {
defer Config().GetAdapter().(*gcfg.AdapterFile).ClearContent()
defer localInstances.Clear()
gres.Dump()
gutil.Dump(Config().GetAdapter().(*gcfg.AdapterFile).GetPaths())
gutil.Dump(Config().GetAdapter().(*gcfg.AdapterFile).GetFileName())
gutil.Dump(Config().GetAdapter().(*gcfg.AdapterFile).GetContent())
gutil.Dump(Config().Data(ctx))
view := View("test1")

View File

@ -8,6 +8,7 @@ package gcfg
import (
"context"
"fmt"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/container/gmap"
@ -257,6 +258,7 @@ func (c *AdapterFile) getJson(fileName ...string) (configJson *gjson.Json, err e
return nil
}
if file := gres.Get(filePath); file != nil {
fmt.Println("retrieve config content from gres:", filePath)
content = string(file.Content())
} else {
content = gfile.GetContents(filePath)