Enable loading TOML & YAML by confdir (#120)

This commit is contained in:
秋のかえで 2021-01-01 20:16:22 +08:00 committed by GitHub
parent 38ec9208d8
commit 9d4038427d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@ import (
"os/signal"
"path"
"path/filepath"
"regexp"
"runtime"
"runtime/debug"
"strings"
@ -120,7 +121,11 @@ func readConfDir(dirPath string) {
log.Fatalln(err)
}
for _, f := range confs {
if strings.HasSuffix(f.Name(), ".json") {
matched, err := regexp.MatchString(`^.+\.(json|toml|yaml|yml)$`, f.Name())
if err != nil {
log.Fatalln(err)
}
if matched {
configFiles.Set(path.Join(dirPath, f.Name()))
}
}