(name string, dir string, contents []byte)
| 222 | } |
| 223 | |
| 224 | func writeFile(name string, dir string, contents []byte) error { |
| 225 | file := filepath.Join(dir, name) |
| 226 | |
| 227 | if err := os.MkdirAll(dir, 0o755); err != nil { //nolint: gosec |
| 228 | return fmt.Errorf("could not create directory %q: %w", dir, err) |
| 229 | } |
| 230 | |
| 231 | if err := os.WriteFile(file, contents, 0o644); err != nil { //nolint: gosec |
| 232 | return err |
| 233 | } |
| 234 | |
| 235 | return nil |
| 236 | } |