all repos — legit @ 60e1092dbcfacb28b30d052b0f73d2249cd63a9d

web frontend for git

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		Readme   []string `yaml:"readme"`
14	} `yaml:"git"`
15	Template struct {
16		Dir string `yaml:"dir"`
17	} `yaml:"template"`
18	Meta struct {
19		Title       string `yaml:"title"`
20		Description string `yaml:"description"`
21	} `yaml:"meta"`
22}
23
24func Read(f string) (*Config, error) {
25	b, err := os.ReadFile(f)
26	if err != nil {
27		return nil, fmt.Errorf("reading config: %w", err)
28	}
29
30	c := Config{}
31	if err := yaml.Unmarshal(b, &c); err != nil {
32		return nil, fmt.Errorf("parsing config: %w", err)
33	}
34
35	return &c, nil
36}