Skip to content

Commit 1369f94

Browse files
authored
Merge pull request #5 from acmcodercom/fix-HandleReadErr
handle read err to break the loop
2 parents 6f7b1ee + ab620e8 commit 1369f94

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

tool/differ.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
)
99

10-
// clearString replace all white chars
10+
// clearString is to replace all white chars
1111
func clearString(str string) string {
1212
trimStr := strings.ReplaceAll(str, " ", "")
1313
trimStr = strings.ReplaceAll(trimStr, "\t", "")
@@ -16,12 +16,13 @@ func clearString(str string) string {
1616
return trimStr
1717
}
1818

19-
// clearEnter replace all '\r' chars
19+
// clearEnter is to replace all '\r' chars
2020
func clearEnter(str string) string {
2121
trimStr := strings.ReplaceAll(str, "\r", "")
2222
return trimStr
2323
}
2424

25+
// getFileContent is to read the file content line by line and do some replaces for each lines
2526
func getFileContent(fileName string, diffIgnoreHead bool, strictMode bool) (string, error) {
2627
src, err := os.Open(fileName)
2728
if err != nil {
@@ -57,7 +58,7 @@ func getFileContent(fileName string, diffIgnoreHead bool, strictMode bool) (stri
5758
}
5859
}
5960
}
60-
if err == io.EOF {
61+
if err != nil {
6162
break
6263
}
6364
}

tool/differ_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestDiffOutFunc(t *testing.T) {
108108
shouldSame: true,
109109
},
110110
{
111-
desc: "(L)The size of user.out is zero",
111+
desc: "(L)The size of file is large than 65535 bytes",
112112
userOut: "userv7.out",
113113
dataOut: "datav7.out",
114114
ignoreHead: false,

0 commit comments

Comments
 (0)