From d05ea66f4bbcf0cc5c8908f3435c68de1b070fa1 Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Sat, 12 Oct 2024 02:52:22 +0300 Subject: Начальная версия MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 pkg/config/config.go (limited to 'pkg/config/config.go') 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) +} -- cgit v1.2.3