diff --git a/config.go b/config.go index 58de2ee..6ef8200 100644 --- a/config.go +++ b/config.go @@ -91,7 +91,13 @@ func Save(target interface{}, file string, overWrite bool) error { return _c.Save(target, file, overWrite) } func (c *config) Save(target interface{}, file string, overWrite bool) error { - return marshalFile(target, file, overWrite) + var absPath string + var err error + if absPath, err = absPathify(file); nil != err { + return err + } + + return marshalFile(target, absPath, overWrite) } // 1. file @@ -101,8 +107,10 @@ func (c *config) getConfigFiles(files ...string) []string { for _, file := range files { // check configuration - if exists(file) { - results = append(results, file) + if absin, err := absPathify(file); nil == err { + if exists(absin) { + results = append(results, absin) + } } }