ing
This commit is contained in:
parent
ee725bc7d4
commit
fa1c6caa6a
15
util.go
15
util.go
|
@ -159,7 +159,6 @@ func getPrefixForStruct(prefixes []string, fieldStruct *reflect.StructField) []s
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalFile(target interface{}, file string, overWrite bool) error {
|
func marshalFile(target interface{}, file string, overWrite bool) error {
|
||||||
var f *os.File
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
var b []byte
|
var b []byte
|
||||||
|
@ -171,21 +170,9 @@ func marshalFile(target interface{}, file string, overWrite bool) error {
|
||||||
if !overWrite {
|
if !overWrite {
|
||||||
return fmt.Errorf("Config: File[%s] is exist", file)
|
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) {
|
func marshal(target interface{}, ext string) ([]byte, error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user