* skip empty lines to avoid issue of #630 * add tests on empty lines and comms
@@ -73,6 +73,9 @@ func FileInit(fileFolder string, filename string, fileType string) error {
if strings.HasPrefix(scanner.Text(), "#") { // allow comments
continue
}
+ if len(scanner.Text()) == 0 { //skip empty lines
+ continue
+ }
switch fileType {
case "regex", "regexp":
dataFileRegex[filename] = append(dataFileRegex[filename], regexp.MustCompile(scanner.Text()))
@@ -178,6 +178,12 @@ func TestFileInit(t *testing.T) {
types: "string",
result: 3,
},
+ {
+ name: "file with type:string and empty lines + commentaries",
+ filename: "test_empty_line.txt",
+ types: "string",
+ result: 3,
+ },
{
name: "file with type:re",
filename: "test_data_re.txt",
@@ -0,0 +1,12 @@
+foo
+
+#toto
+bar
+baz