-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
50 lines (45 loc) · 1.1 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"encoding/json"
"os"
"yubari/mastodon"
"yubari/meili"
"yubari/pixiv"
"yubari/rss"
"yubari/telegram"
)
type Config struct {
File string
BeanstalkAddr string `json:"beanstalkAddr"`
Redis *RedisConfig `json:"redis"`
Mastodon *mastodon.Config `json:"mastodon"`
Telegram *telegram.Config `json:"telegram"`
Pixiv *pixiv.Config `json:"pixiv"`
RSS *rss.Config `json:"rss"`
Meilisearch *meili.Config `json:"meilisearch"`
SentryDSN string `json:"sentry"`
}
type RedisConfig struct {
Addr string `json:"addr"`
Password string `json:"password"`
DB int `json:"db"`
}
func ReadConfig(cfgfile *string) (cfg *Config) {
cfg = &Config{
File: *cfgfile,
BeanstalkAddr: "localhost:11300",
Redis: &RedisConfig{
Addr: "localhost:6379",
Password: "",
DB: 0,
},
Telegram: &telegram.Config{},
Meilisearch: &meili.Config{},
}
file, e := os.ReadFile(*cfgfile)
if e != nil {
logger.Fatalf("Configfile error (%v)\n", e)
}
json.Unmarshal(file, cfg)
return cfg
}