From 5f6e1775e2db7c2d00c50b6a77dcbf330bd7dfc7 Mon Sep 17 00:00:00 2001 From: steden <1470804@qq.com> Date: Tue, 20 Feb 2024 23:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9AyamlConfig.LoadConte?= =?UTF-8?q?nt=E6=96=B9=E6=B3=95=E8=A7=A3=E6=9E=90yml=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configure/yamlConfig.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure/yamlConfig.go b/configure/yamlConfig.go index 21716d03b..bb022d074 100644 --- a/configure/yamlConfig.go +++ b/configure/yamlConfig.go @@ -34,6 +34,19 @@ func (r *yamlConfig) LoadConfigure() error { return nil } +// LoadContent 解析yml内容 +func (r *yamlConfig) LoadContent(data []byte) error { + var m map[string]any + err := yaml.Unmarshal(data, &m) + if err != nil { + return err + } + + // 结构化转成扁平化 + r.flattening("", m) + return nil +} + func (r *yamlConfig) Get(key string) (any, bool) { v, exists := r.data[key] if exists {