Init initializes a config file
(confpath string, configs string)
| 8 | |
| 9 | // Init initializes a config file |
| 10 | func Init(confpath string, configs string) error { |
| 11 | |
| 12 | // assert that the config directory exists |
| 13 | if err := os.MkdirAll(filepath.Dir(confpath), 0755); err != nil { |
| 14 | return fmt.Errorf("failed to create directory: %v", err) |
| 15 | } |
| 16 | |
| 17 | // write the config file |
| 18 | if err := os.WriteFile(confpath, []byte(configs), 0644); err != nil { |
| 19 | return fmt.Errorf("failed to create file: %v", err) |
| 20 | } |
| 21 | |
| 22 | return nil |
| 23 | } |
no outgoing calls