all repos — legit @ ac6ca71f01885b3fff692b4b9ee36ed33965d396

web frontend for git, written in go

config/config.go (view raw)

 1package config
 2
 3import (
 4	"fmt"
 5	"os"
 6
 7	"gopkg.in/yaml.v3"
 8)
 9
10type Config struct {
11	Git struct {
12		ScanPath string `yaml:"scanPath"`
13	} `yaml:"git"`
14	Template struct {
15		Dir string `yaml:"dir"`
16	} `yaml:"template"`
17	Meta struct {
18		Title       string `yaml:"title"`
19		Description string `yaml:"description"`
20	} `yaml:"meta"`
21}
22
23func Read(f string) (*Config, error) {
24	b, err := os.ReadFile(f)
25	if err != nil {
26		return nil, fmt.Errorf("reading config: %w", err)
27	}
28
29	c := Config{}
30	if err := yaml.Unmarshal(b, &c); err != nil {
31		return nil, fmt.Errorf("parsing config: %w", err)
32	}
33
34	return &c, nil
35}