From fa1c6caa6a5208640e3067fc4c09896f367e1a71 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 13 Oct 2017 12:25:55 +0900 Subject: [PATCH] ing --- util.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/util.go b/util.go index bd601bb..f509f65 100644 --- a/util.go +++ b/util.go @@ -159,7 +159,6 @@ func getPrefixForStruct(prefixes []string, fieldStruct *reflect.StructField) []s } func marshalFile(target interface{}, file string, overWrite bool) error { - var f *os.File var err error var b []byte @@ -171,21 +170,9 @@ func marshalFile(target interface{}, file string, overWrite bool) error { if !overWrite { return fmt.Errorf("Config: File[%s] is exist", file) } - if f, err = os.OpenFile(file, os.O_WRONLY, os.ModeAppend); nil != err { - return err - } - } else { - if f, err = os.Create(file); nil != err { - return err - } } - defer f.Close() - - if _, err = f.Write(b); nil != err { - return err - } - return nil + return ioutil.WriteFile(file, b, os.ModeAppend) } func marshal(target interface{}, ext string) ([]byte, error) {