config: Ensure we always have an absolute path Having this consistent across the code is handy when we're building paths, counting separators and other path manipulation.
Daniele Sluijters daenney@users.noreply.github.com
Tue, 03 Jan 2023 14:35:36 +0100
1 files changed,
11 insertions(+),
0 deletions(-)
jump to
M
config/config.go
→
config/config.go
@@ -3,6 +3,7 @@
import ( "fmt" "os" + "path/filepath" "gopkg.in/yaml.v3" )@@ -38,6 +39,16 @@
c := Config{} if err := yaml.Unmarshal(b, &c); err != nil { return nil, fmt.Errorf("parsing config: %w", err) + } + + if c.Repo.ScanPath, err = filepath.Abs(c.Repo.ScanPath); err != nil { + return nil, err + } + if c.Dirs.Templates, err = filepath.Abs(c.Dirs.Templates); err != nil { + return nil, err + } + if c.Dirs.Static, err = filepath.Abs(c.Dirs.Static); err != nil { + return nil, err } return &c, nil