blob: 2d97609a9157b81c6cb55ea0c23834099f14f873 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package config
import (
"os"
"gopkg.in/yaml.v3"
"neonxp.ru/go/framework/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"`
}
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)
}
|