ShOrgRu/pkg/config/config.go

28 lines
527 B
Go
Raw Normal View History

2024-10-06 17:04:37 +03:00
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"`
Host string `yaml:"host"`
Admins map[string]string `yaml:"admins"`
Keypairs []string `yaml:"keys"`
2024-10-06 17:04:37 +03:00
}
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)
}