Trace back everything (tested)

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-21 19:19:17 +08:00
parent 3f44d2d9c2
commit 5f6eb9f2a2
16 changed files with 229 additions and 84 deletions

View File

@@ -1,7 +1,7 @@
package config
import (
"log/slog"
"log"
"os"
"strings"
@@ -29,11 +29,9 @@ func Init() {
conf := &config{}
if err := viper.ReadInConfig(); err != nil {
// Dont generate config when using dev mode
slog.Error("[Config] Can't read config!", "err", err)
os.Exit(1)
log.Fatalln("[Config] Can't read config!")
}
if err := viper.Unmarshal(conf); err != nil {
slog.Error("[Condig] Can't unmarshal config!", "err", err)
os.Exit(1)
log.Fatalln("[Condig] Can't unmarshal config!")
}
}

View File

@@ -17,27 +17,32 @@ type server struct {
Address string `yaml:"address"`
ExternalUrl string `yaml:"external_url"`
DebugMode string `yaml:"debug_mode"`
LogLevel string `yaml:"log_level"`
ServiceName string `yaml:"service_name"`
}
type database struct {
Type string `yaml:"type"`
Host string `yaml:"host"`
Name string `yaml:"name"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Type string `yaml:"type"`
Host string `yaml:"host"`
Name string `yaml:"name"`
Username string `yaml:"username"`
Password string `yaml:"password"`
ServiceName string `yaml:"service_name"`
}
type cache struct {
Hosts []string `yaml:"hosts"`
Master string `yaml:"master"`
Username string `yaml:"username"`
Password string `yaml:"passowrd"`
DB int `yaml:"db"`
Hosts []string `yaml:"hosts"`
Master string `yaml:"master"`
Username string `yaml:"username"`
Password string `yaml:"passowrd"`
DB int `yaml:"db"`
ServiceName string `yaml:"service_name"`
}
type search struct {
Host string `yaml:"host"`
ApiKey string `yaml:"api_key"`
Host string `yaml:"host"`
ApiKey string `yaml:"api_key"`
ServiceName string `yaml:"service_name"`
}
type email struct {