未读取到配置报错提示

This commit is contained in:
ayflying
2025-05-14 16:41:53 +08:00
parent 374fdac477
commit d471b46c14

View File

@@ -9,6 +9,7 @@ import (
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gres"
"github.com/gogf/gf/v2/text/gstr"
@@ -98,6 +99,9 @@ func (c *Cfg) GetFile(filename string, _pathStr ...string) (jsonObj *gjson.Json,
}
}
}
if bytes == nil {
g.Log().Errorf(gctx.New(), "未读取到配置文件:%v", filePath)
}
// 解析 JSON 内容并返回结果
jsonObj, err = gjson.DecodeToJson(bytes)