diff options
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r-- | pkg/config/config.go | 27 |
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) +} |