Skip to content

Commit 2d822f4

Browse files
Process each file as it is found.
1 parent 39343ad commit 2d822f4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

files.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ func (f *File) Delete() {
3131
os.Remove(f.Path)
3232
}
3333

34+
func newFile(path string) *File {
35+
f := new(File)
36+
37+
f.Path = path
38+
f.Key = filepath.Base(path)
39+
40+
return f
41+
}
42+
3443
func scrapeFiles() {
3544
if conf.LocalPath == "" {
3645
return
@@ -51,15 +60,11 @@ func scrapeFiles() {
5160
return nil
5261
}
5362

54-
files = append(files, &File{Path: path, Key: filepath.Base(path)})
55-
56-
return nil
57-
})
58-
59-
for i := range files {
60-
f := files[i]
63+
f := newFile(path)
6164
f.Read()
6265
f.Process()
6366
f.Delete()
64-
}
67+
68+
return nil
69+
})
6570
}

0 commit comments

Comments
 (0)