Fix Unexpected Newline in Output when Copying Empty Files #31
Labels
bug
Something isn't working as expected
refactoring
Issues or PRs to improving code structure, without changing its external behavior
testing
Issues or PRs specifically related to Go testing frameworks or practices.
During a code review of Pull Request #29, it was discovered that when
ParseContent
is used to copy content from an empty file, the output contains an unexpected newline character (\n
) instead of an empty string. This behavior was observed in the following scenario:readers
slice passed toParseContent
contains aFileContentReader
where theFilePath
points to an empty file."\n"
) instead of an empty string (""
).Expected Behavior:
When copying content from an empty file,
ParseContent
should return an empty string to accurately reflect the lack of content in the file.Proposed Fix:
Add a check within the loop in
ParseContent
to ensure that thecontent
read from each reader is not empty before appending a newline character and writing it to thestrings.Builder
.Additional Notes:
ParseContent
to ensure they cover the case of empty file input.Originally posted by @ccoVeille in #29 (comment)
The text was updated successfully, but these errors were encountered: