aboutsummaryrefslogtreecommitdiff
path: root/pkg/config
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-06 17:04:37 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-06 17:04:37 +0300
commit6160b4fdc5f37e4ceaa6b3c5acc855f466049d61 (patch)
treeb6e41f9cad22515a61cc50b0a82d98ee55e0c3e3 /pkg/config
parent81b13617c4d0ca68afb181d1105386f0c339864d (diff)
Первая версия
Diffstat (limited to 'pkg/config')
-rw-r--r--pkg/config/config.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
new file mode 100644
index 0000000..342012e
--- /dev/null
+++ b/pkg/config/config.go
@@ -0,0 +1,25 @@
+package config
+
+import (
+ "os"
+
+ "gopkg.in/yaml.v3"
+ "sh.org.ru/pkg/db"
+)
+
+type Config struct {
+ Debug bool `yaml:"debug"`
+ DB *db.Config `yaml:"db"`
+ Listen string `yaml:"listen"`
+ Admins map[string]string `yaml:"admins"`
+}
+
+func New(file string) (*Config, error) {
+ cfg := new(Config)
+ fp, err := os.Open(file)
+ if err != nil {
+ return nil, err
+ }
+
+ return cfg, yaml.NewDecoder(fp).Decode(cfg)
+}