Skip to content

Commit 7d9fd2d

Browse files
committed
still brute-force searching for solution
1 parent a87cd17 commit 7d9fd2d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

utils/config/config.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package config
33
import (
44
"os"
55
"path/filepath"
6-
"strconv"
76
"strings"
87
"sync"
98

@@ -53,28 +52,32 @@ func WatchFile(path string, f *file.File) {
5352
})
5453
}
5554

56-
func LoadDir(path string, dir string, config *koanf.Koanf, parser koanf.Parser) []map[string]any {
55+
func LoadDir(path string, dir string, config *koanf.Koanf, parser koanf.Parser) error {
5756
files, err := filepath.Glob(filepath.Join(dir, "*.yml"))
5857

5958
if err != nil {
6059
return nil
6160
}
6261

63-
for i, f := range files {
62+
var array []any
63+
64+
for _, f := range files {
6465
tmp := koanf.New(".")
6566

66-
LoadFile(f, tmp, parser)
67+
_, err := LoadFile(f, tmp, parser)
6768

68-
wrapper := map[string]any{
69-
path: map[string]any{
70-
strconv.Itoa(i): tmp.Raw(),
71-
},
69+
if err != nil {
70+
return err
7271
}
7372

74-
config.Load(confmap.Provider(wrapper, "."), nil);
73+
array = append(array, tmp.Raw())
74+
}
75+
76+
wrapper := map[string]any{
77+
path: array,
7578
}
7679

77-
return nil
80+
return config.Load(confmap.Provider(wrapper, "."), nil)
7881
}
7982

8083
func LoadEnv(config *koanf.Koanf) (koanf.Provider, error) {

0 commit comments

Comments
 (0)