(path string, data map[string]any)
| 136 | } |
| 137 | |
| 138 | func writeTOML(path string, data map[string]any) error { |
| 139 | if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { |
| 140 | return fmt.Errorf("editorconfig: mkdir %s: %w", filepath.Dir(path), err) |
| 141 | } |
| 142 | encoded, err := toml.Marshal(data) |
| 143 | if err != nil { |
| 144 | return fmt.Errorf("editorconfig: marshal %s: %w", path, err) |
| 145 | } |
| 146 | if err := os.WriteFile(path, encoded, 0o600); err != nil { |
| 147 | return fmt.Errorf("editorconfig: write %s: %w", path, err) |
| 148 | } |
| 149 | return nil |
| 150 | } |