aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.go39
1 files changed, 24 insertions, 15 deletions
diff --git a/config/config.go b/config/config.go
index 8678f52..bbb327c 100644
--- a/config/config.go
+++ b/config/config.go
@@ -108,21 +108,30 @@ func Parse(r io.Reader) (c *config, err error) {
return
}
-func ParseFile(file string) (c *config, err error) {
- f, err := os.Open(file)
- if err != nil {
- return
- }
- defer f.Close()
-
- info, err := f.Stat()
- if err != nil {
- return
+func ParseFiles(files []string) (c *config, err error) {
+ var lastErr error
+ for _, file := range files {
+ f, err := os.Open(file)
+ if err != nil {
+ lastErr = err
+ if os.IsNotExist(err) {
+ continue
+ }
+ return nil, err
+ }
+ defer f.Close()
+ info, err := f.Stat()
+ if err != nil {
+ lastErr = err
+ return nil, err
+ }
+ if info.IsDir() {
+ continue
+ }
+ return Parse(f)
}
-
- if info.IsDir() {
- return nil, errors.New("invalid config file")
+ if lastErr == nil {
+ lastErr = errors.New("invalid config file")
}
-
- return Parse(f)
+ return nil, lastErr
}