2026-04-25 01:18:30 +08:00

19 lines
367 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package configx
import (
"os"
"gopkg.in/yaml.v3"
)
// LoadYAML 把指定 YAML 文件反序列化到已有配置对象里。
// 调用方通常会先准备一个带默认值的 struct再让 YAML 局部覆盖它。
func LoadYAML(path string, out any) error {
body, err := os.ReadFile(path)
if err != nil {
return err
}
return yaml.Unmarshal(body, out)
}