createFileWriter creates a buffered file writer with a new file The caller should flush the writer before closing the file. Returns the file handle as it needs to be closed when writing is complete
(directory types.Path)
| 190 | // The caller should flush the writer before closing the file. |
| 191 | // Returns the file handle as it needs to be closed when writing is complete |
| 192 | func createFileWriter(directory types.Path) (*bufio.Writer, *os.File, error) { |
| 193 | filePath := filepath.Join(string(directory), "content") |
| 194 | file, err := os.Create(filePath) |
| 195 | if err != nil { |
| 196 | return nil, nil, fmt.Errorf("failed to create file: %w", err) |
| 197 | } |
| 198 | |
| 199 | return bufio.NewWriter(file), file, nil |
| 200 | } |
no test coverage detected