aboutsummaryrefslogblamecommitdiff
path: root/pkg/config/config.go
blob: 342012eabfb49a2a174a9d5b6c4ced2c0c291765 (plain) (tree)
























                                                   
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)
}