all repos — legit @ 7a6ff3565e8e5f55d50c509c9ee12438b61c850e

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}