update go mod, fix get config to use os.Root
This commit is contained in:
+11
-3
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user