aboutsummaryrefslogtreecommitdiffstats
path: root/internal/config.go
blob: 9a1bc5f896e72d900e4fd53ecdebe31e8250293e (plain)
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
28
29
30
31
32
33
package config

import (
	"os"

	"gopkg.in/yaml.v3"
)

type Config struct {
	Server struct {
		Host string `yaml:"host"`
		Port string `yaml:"port"`
	} `yaml:"server"`
	Database struct {
		ConnString string `yaml:"connString"`
	} `yaml:"database"`
	Conference struct {
		ScheduleURL string `yaml:"scheduleURL"`
	} `yaml:"conference"`
	AcceptRegistrations bool `yaml:"acceptRegistrations"`
}

func ReadConfig(configPath string, dst *Config) error {
	config, err := os.ReadFile(configPath)
	if err != nil {
		return err
	}

	if err := yaml.Unmarshal(config, dst); err != nil {
		return err
	}
	return nil
}