all repos — elgit @ 856f66808b913baff13c815daec3cdde7121e3bd

fork of legit: web frontend for git, written in go

all: init

commit

856f66808b913baff13c815daec3cdde7121e3bd

1 file changed, 35 insertions(+), 0 deletions(-)

changed files
A config/config.go
@@ -0,0 +1,35 @@
+package config + +import ( + "fmt" + "os" + + "gopkg.in/yaml.v3" +) + +type Config struct { + Git struct { + ScanPath string `yaml:"scanPath"` + } `yaml:"git"` + Template struct { + Dir string `yaml:"dir"` + } `yaml:"template"` + Meta struct { + Title string `yaml:"title"` + Description string `yaml:"description"` + } `yaml:"meta"` +} + +func Read(f string) (*Config, error) { + b, err := os.ReadFile(f) + if err != nil { + return nil, fmt.Errorf("reading config: %w", err) + } + + c := Config{} + if err := yaml.Unmarshal(b, &c); err != nil { + return nil, fmt.Errorf("parsing config: %w", err) + } + + return &c, nil +}