diff options
| author | dev | 2026-06-24 01:52:52 +0200 |
|---|---|---|
| committer | dev | 2026-06-24 01:52:52 +0200 |
| commit | 7af896fce4eac0579076aa15a3e987345dc9f9e8 (patch) | |
| tree | 2bbca47a18a4a4bee735d92cccf91d5ee307e498 /src/main.go | |
| parent | ae17ca2716cee24b9814a5e54c2349c115012d74 (diff) | |
| download | hnimdbbot-7af896fce4eac0579076aa15a3e987345dc9f9e8.tar.gz | |
feat: switch config to JSON; add go.mod and config.json.example
- Replace Viper-based config with encoding/json (config.go)
- Add config.json with sensible defaults (gitignored)
- Add config.json.example with empty values as reference
- Initialize go module (go.mod)
- Update main.go to use LoadConfig()
Diffstat (limited to 'src/main.go')
| -rw-r--r-- | src/main.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main.go b/src/main.go index 8596cd1..ebfbd98 100644 --- a/src/main.go +++ b/src/main.go @@ -25,11 +25,12 @@ type App struct { } func main() { - var err error - _own_conf := _conf - app := App{Config: &_own_conf} - _conf = Config{} + cfg, err := LoadConfig("config.json") + if err != nil { + log.Fatalf("failed to load config: %v", err) + } + app := App{Config: cfg} app.Now = time.Now() log.Debug(fmt.Sprintf(`Connecting to "%s" database "%s" as user "%s" on host "%s:%s" with extra options "%s".`, app.Config.DBDriver, app.Config.DBDBName, app.Config.DBUser, app.Config.DBHost, app.Config.DBPort, app.Config.DBOptions)) |
