aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2022-01-27 12:05:15 +0000
committerr <r@freesoftwareextremist.com>2022-01-27 12:05:15 +0000
commitb8c0133bcd5e7f1d4063ad992949cc19d18e7aad (patch)
tree5322b83d194c9ffcb498627bdd16175f9508d87d /config
parent54c42455f393c5ae8ebdb19884d40ebd9a18f755 (diff)
parent4ef5e0daf285f41850c9ac53b0322d85fbf5eaec (diff)
downloadbloat-b8c0133bcd5e7f1d4063ad992949cc19d18e7aad.tar.gz
bloat-b8c0133bcd5e7f1d4063ad992949cc19d18e7aad.zip
Merge branch 'master' into absolute_fluoride
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
}