修改配置写入

This commit is contained in:
junleea 2025-09-06 14:42:49 +08:00
parent b1bb1cb734
commit 44b74e468b
1 changed files with 1 additions and 19 deletions

View File

@ -126,25 +126,7 @@ func ReadConfig(path string) error {
fmt.Println("Config file not found!")
//创建默认配置
DefaultConfig()
//写入json文件
file, err := os.Create(path)
if err != nil {
fmt.Println("Error creating config file")
return err
}
defer file.Close()
encoder := json.NewEncoder(file)
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")
}
return err
WriteConfigToFile()
}
//读json文件