aboutsummaryrefslogtreecommitdiff
path: root/pkg/config
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-12 02:52:22 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-12 02:53:52 +0300
commitd05ea66f4bbcf0cc5c8908f3435c68de1b070fa1 (patch)
tree7c7a769206646f2b81a0eda0680f0be5033a4197 /pkg/config
Начальная версияv0.0.1
Diffstat (limited to 'pkg/config')
-rw-r--r--pkg/config/config.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
new file mode 100644
index 0000000..6a9d30c
--- /dev/null
+++ b/pkg/config/config.go
@@ -0,0 +1,27 @@
+package config
+
+import (
+ "os"
+
+ "go.neonxp.ru/framework/pkg/db"
+ "gopkg.in/yaml.v3"
+)
+
+type Config struct {
+ Debug bool `yaml:"debug"`
+ DB *db.Config `yaml:"db"`
+ Listen string `yaml:"listen"`
+ Host string `yaml:"host"`
+ Admins map[string]string `yaml:"admins"`
+ Keypairs []string `yaml:"keys"`
+}
+
+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)
+}