SaveConfigYAML write configuration to yaml file
(filename string, config *ConfigStructure)
| 338 | |
| 339 | // SaveConfigYAML write configuration to yaml file |
| 340 | func SaveConfigYAML(filename string, config *ConfigStructure) error { |
| 341 | f, err := os.Create(filename) |
| 342 | if err != nil { |
| 343 | return err |
| 344 | } |
| 345 | defer func() { |
| 346 | _ = f.Close() |
| 347 | }() |
| 348 | |
| 349 | yamlData, err := yaml.Marshal(&config) |
| 350 | if err != nil { |
| 351 | return fmt.Errorf("error marshaling to YAML: %s", err) |
| 352 | } |
| 353 | |
| 354 | _, err = f.Write(yamlData) |
| 355 | return err |
| 356 | } |
| 357 | |
| 358 | // GetRootDir returns the RootDir with expanded ~ as home directory |
| 359 | func (conf *ConfigStructure) GetRootDir() string { |