|
@@ -10,6 +10,12 @@ import (
|
|
|
"reflect"
|
|
|
)
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func LoadYamlFile(yamlFilePath string, retObjects *[]any) error {
|
|
|
yamlFile, err := os.Open(yamlFilePath)
|
|
|
if err != nil {
|
|
@@ -26,6 +32,12 @@ func LoadYamlFile(yamlFilePath string, retObjects *[]any) error {
|
|
|
return loadYaml(yamlFile, retObjects)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func LoadYamlBytes(yamlBytes []byte, retObjects *[]any) error {
|
|
|
return loadYaml(bytes.NewReader(yamlBytes), retObjects)
|
|
|
}
|
|
@@ -39,7 +51,7 @@ func loadYaml(r io.Reader, retObjects *[]any) error {
|
|
|
retObjectType := reflect.TypeOf(retObject)
|
|
|
|
|
|
if retObjectType.Kind() != reflect.Ptr && retObjectType.Kind() != reflect.Map {
|
|
|
- return errors.New("返回对象slice元素需要指针或者map")
|
|
|
+ return errors.New("返回对象slice需要指针或者map")
|
|
|
}
|
|
|
|
|
|
err := decoder.Decode(retObject)
|