update go mod, fix get config to use os.Root

This commit is contained in:
2026-05-28 20:05:20 +00:00
parent 08cd4dfaaa
commit 9b7404c8d6
2 changed files with 24 additions and 16 deletions
+11 -3
View File
@@ -22,15 +22,23 @@ import (
// get config file from configPath
func GetConfig(configPath string) Config {
content, err := os.ReadFile(configPath)
root, err := os.OpenRoot(".")
if err != nil {
log.Fatal("[Error] when opening config file: ", err)
log.Fatal("Error when opening root dir: ", err)
}
defer root.Close()
content, err := root.ReadFile(configPath)
if err != nil {
log.Fatal("Error when opening config file: ", err)
}
var config Config
err = json.Unmarshal(content, &config)
if err != nil {
log.Fatal("[Error] during parsing config file: ", err)
log.Fatal("Error during parsing config file: ", err)
}
return config
}