diff --git a/common/yaml/yaml.go b/common/yaml/yaml.go
index 79e5f67d8f673abde88042ed03865f579139cb30..b4c135c7a9352566859c677f3d24a38f0bfceddf 100644
--- a/common/yaml/yaml.go
+++ b/common/yaml/yaml.go
@@ -10,17 +10,24 @@ import (
"gopkg.in/yaml.v2"
)
-func UnmarshalYMLConfig(yamlFile string, out interface{}) error {
- if path.Ext(yamlFile) != ".yml" {
- return perrors.Errorf("yamlFile name{%v} suffix must be .yml", yamlFile)
+// loadYMLConfig Load yml config byte from file
+func loadYMLConfig(confProFile string) ([]byte, error) {
+ if len(confProFile) == 0 {
+ return nil, perrors.Errorf("application configure(provider) file name is nil")
}
- confFileStream, err := ioutil.ReadFile(yamlFile)
- if err != nil {
- return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", yamlFile, perrors.WithStack(err))
+
+ if path.Ext(confProFile) != ".yml" {
+ return nil, perrors.Errorf("application configure file name{%v} suffix must be .yml", confProFile)
}
- err = yaml.Unmarshal(confFileStream, out)
+
+ return ioutil.ReadFile(confProFile)
+}
+
+// unmarshalYMLConfig Load yml config byte from file , then unmarshal to object
+func UnmarshalYMLConfig(confProFile string, out interface{}) error {
+ confFileStream, err := loadYMLConfig(confProFile)
if err != nil {
- return perrors.Errorf("yaml.Unmarshal() = error:%v", perrors.WithStack(err))
+ return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confProFile, perrors.WithStack(err))
}
- return nil
+ return yaml.Unmarshal(confFileStream, out)
}
diff --git a/config/base_config.go b/config/base_config.go
index 6d5ec7e2498ba65b2a6833b6c9cefcb3394e60df..787297c1857647aa570f4404d2365e49174bda1c 100644
--- a/config/base_config.go
+++ b/config/base_config.go
@@ -18,8 +18,6 @@
package config
import (
- "io/ioutil"
- "path"
"reflect"
"strconv"
"strings"
@@ -27,7 +25,6 @@ import (
import (
perrors "github.com/pkg/errors"
- "gopkg.in/yaml.v2"
)
import (
@@ -366,25 +363,3 @@ func initializeStruct(t reflect.Type, v reflect.Value) {
}
}
-
-// loadYMLConfig Load yml config byte from file
-func loadYMLConfig(confProFile string) ([]byte, error) {
- if len(confProFile) == 0 {
- return nil, perrors.Errorf("application configure(provider) file name is nil")
- }
-
- if path.Ext(confProFile) != ".yml" {
- return nil, perrors.Errorf("application configure file name{%v} suffix must be .yml", confProFile)
- }
-
- return ioutil.ReadFile(confProFile)
-}
-
-// unmarshalYMLConfig Load yml config byte from file , then unmarshal to object
-func unmarshalYMLConfig(confProFile string, out interface{}) error {
- confFileStream, err := loadYMLConfig(confProFile)
- if err != nil {
- return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confProFile, perrors.WithStack(err))
- }
- return yaml.Unmarshal(confFileStream, out)
-}