From 2cb005e8ed8a1aeefc51f58976b5735bab6711e3 Mon Sep 17 00:00:00 2001 From: ayflying Date: Wed, 14 May 2025 16:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E5=8F=96=E5=88=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index f1891f7..d31dfb9 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -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)