diff --git a/config.go b/config.go index 6ef8200..cec86e7 100644 --- a/config.go +++ b/config.go @@ -41,7 +41,7 @@ func init() { func SetConfigPath(in string) error { return _c.SetConfigPath(in) } func (c *config) SetConfigPath(in string) error { if in != "" { - absin, err := absPathify(in) + absin, err := ABSPathify(in) if nil != err { return err } @@ -93,7 +93,7 @@ func Save(target interface{}, file string, overWrite bool) error { func (c *config) Save(target interface{}, file string, overWrite bool) error { var absPath string var err error - if absPath, err = absPathify(file); nil != err { + if absPath, err = ABSPathify(file); nil != err { return err } @@ -107,8 +107,8 @@ func (c *config) getConfigFiles(files ...string) []string { for _, file := range files { // check configuration - if absin, err := absPathify(file); nil == err { - if exists(absin) { + if absin, err := ABSPathify(file); nil == err { + if Exists(absin) { results = append(results, absin) } } @@ -116,8 +116,8 @@ func (c *config) getConfigFiles(files ...string) []string { for _, file := range files { // check configuration - if absin, err := absPathify(filepath.Join(c.configPath, file)); nil == err { - if exists(absin) { + if absin, err := ABSPathify(filepath.Join(c.configPath, file)); nil == err { + if Exists(absin) { results = append(results, absin) } } diff --git a/util.go b/util.go index 594bd14..4024a9d 100644 --- a/util.go +++ b/util.go @@ -16,7 +16,7 @@ import ( yaml "gopkg.in/yaml.v2" ) -func absPathify(inPath string) (string, error) { +func ABSPathify(inPath string) (string, error) { if strings.HasPrefix(inPath, "$HOME") { inPath = userHomeDir() + inPath[5:] } @@ -49,7 +49,7 @@ func userHomeDir() string { return os.Getenv("HOME") } -func exists(path string) bool { +func Exists(path string) bool { if fileInfo, err := os.Stat(path); err == nil && fileInfo.Mode().IsRegular() { return true } @@ -161,7 +161,7 @@ func getPrefixForStruct(prefixes []string, fieldStruct *reflect.StructField) []s func marshalFile(target interface{}, file string, overWrite bool) error { var f *os.File var err error - if exists(file) { + if Exists(file) { if !overWrite { return fmt.Errorf("Config: File[%s] is exist", file) }