SaveConfig write configuration to json file
(filename string, config *ConfigStructure)
| 305 | |
| 306 | // SaveConfig write configuration to json file |
| 307 | func SaveConfig(filename string, config *ConfigStructure) error { |
| 308 | f, err := os.Create(filename) |
| 309 | if err != nil { |
| 310 | return err |
| 311 | } |
| 312 | defer func() { |
| 313 | _ = f.Close() |
| 314 | }() |
| 315 | |
| 316 | encoded, err := json.MarshalIndent(&config, "", " ") |
| 317 | if err != nil { |
| 318 | return err |
| 319 | } |
| 320 | |
| 321 | _, err = f.Write(encoded) |
| 322 | return err |
| 323 | } |
| 324 | |
| 325 | // SaveConfigRaw write configuration to file |
| 326 | func SaveConfigRaw(filename string, conf []byte) error { |