@@ -35,29 +35,13 @@ func Marshal(valuePtr any, extension string) ([]byte, error) {
35
35
func Unmarshal (data []byte , extension string , valuePtr any ) error {
36
36
switch extension {
37
37
case ".json" :
38
- err := unmarshalJSON (data , valuePtr )
39
- if err != nil {
40
- return errors .WithStack (err )
41
- }
42
- return nil
38
+ return errors .WithStack (unmarshalJSON (data , valuePtr ))
43
39
case ".yml" , ".yaml" :
44
- err := unmarshalYaml (data , valuePtr )
45
- if err != nil {
46
- return errors .WithStack (err )
47
- }
48
- return nil
40
+ return errors .WithStack (unmarshalYaml (data , valuePtr ))
49
41
case ".toml" :
50
- err := unmarshalToml (data , valuePtr )
51
- if err != nil {
52
- return errors .WithStack (err )
53
- }
54
- return nil
42
+ return errors .WithStack (unmarshalToml (data , valuePtr ))
55
43
case ".xml" :
56
- err := unmarshalXML (data , valuePtr )
57
- if err != nil {
58
- return errors .WithStack (err )
59
- }
60
- return nil
44
+ return errors .WithStack (unmarshalXML (data , valuePtr ))
61
45
}
62
46
return errors .Errorf ("Unsupported file format '%s' for config file" , extension )
63
47
}
@@ -98,11 +82,7 @@ func WriteFile(path string, value any) error {
98
82
return errors .WithStack (err )
99
83
}
100
84
101
- err = os .WriteFile (path , data , 0644 )
102
- if err != nil {
103
- return errors .WithStack (err )
104
- }
105
- return nil
85
+ return errors .WithStack (os .WriteFile (path , data , 0644 ))
106
86
}
107
87
108
88
func IsSupportedExtension (ext string ) bool {
0 commit comments