修改初始无配置默认配置写入问题

This commit is contained in:
junleea 2025-08-04 21:06:44 +08:00
parent 301817c353
commit 2e807710bc
1 changed files with 7 additions and 1 deletions

View File

@ -128,7 +128,13 @@ func ReadConfig(path string) error {
}
defer file.Close()
encoder := json.NewEncoder(file)
err = encoder.Encode(&Config)
configData, err2 := json.MarshalIndent(Config, "", " ")
if err2 != nil {
log.Println("WriteConfigToFile json marshal error:", err)
return err2
}
err = encoder.Encode(string(configData))
if err != nil {
fmt.Println("Error encoding config")
}