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