Skip to content

Commit

Permalink
新增:yamlConfig.LoadContent方法解析yml格式
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Feb 20, 2024
1 parent b0f6540 commit 5f6e177
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions configure/yamlConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5f6e177

Please sign in to comment.